https://github.com/s0ftik3/rayso-api
🎨 Ray.so API for JavaScript (Node.js). Turn your code into beautiful images.
https://github.com/s0ftik3/rayso-api
api code-highlight ray-so ray-so-api
Last synced: about 1 month ago
JSON representation
🎨 Ray.so API for JavaScript (Node.js). Turn your code into beautiful images.
- Host: GitHub
- URL: https://github.com/s0ftik3/rayso-api
- Owner: s0ftik3
- License: mit
- Created: 2022-01-26T17:58:24.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T18:14:58.000Z (about 3 years ago)
- Last Synced: 2025-10-23T20:15:50.687Z (4 months ago)
- Topics: api, code-highlight, ray-so, ray-so-api
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/rayso-api
- Size: 911 KB
- Stars: 19
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ray.so API
[](https://npmjs.com/package/rayso-api)
[](https://www.npmjs.com/package/rayso-api)
[](https://t.me/vychs)
[](https://npmjs.com/package/rayso-api)
This is unofficial NodeJs (JavaScript) API for [ray.so](https://ray.so) that turns your code into beautiful images. Choose from a range of syntax colors, hide or show the background, and toggle between a dark and light window.
## Navigation
- [Installing](#installing)
- [Usage](#usage)
- [Parameters](#parameters)
- [Examples](#examples)
- [Default](#default-output)
- [Custom](#custom-parameters)
- [No Background](#output-without-background)
- [Themes](#themes)
- [Candy](#candy)
- [Crimson](#crimson)
- [Falcon](#falcon)
- [Meadow](#meadow)
- [Midnight](#midnight)
- [Raindrop](#raindrop)
- [Sunset](#sunset)
- [Credits](#credits)
## Installing
```bash
$ npm i rayso-api
```
## Usage
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({
// parameters, if you want to customize the output
// you'll find detailed info about parameters below
})
raySo
.cook(`console.log('Hello, World!');`)
.then(response => {
// response is image buffer
})
.catch(err => {
console.error(err)
})
```
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo()
```
## Parameters
| Parameter | Default value | Type | Description |
|--------------------|--------------------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `title ` | `"Untitled-1"` | String | The title will be displayed on top of the code box. |
| `theme` | `"breeze"` | String | There are several options of how your box will look like. Available themes: breeze, candy, crimson, falcon, meadow, midnight, raindrop, sunset |
| `background` | `true` | Boolean | If disabled, it will create an image of code box only, without background. |
| `darkMode` | `true` | Boolean | If disabled, it will change your theme to its light version. |
| `padding` | `32` | String or Number | Distance between borders and code box. Available values: 16, 32, 64 and 128. |
| `language` | `"auto"` | String | You better leave it auto :/ However, you can try to pass some language name and if it worked, good for you! |
| `localPreview` | `false` | Boolean | If enabled, it will create example.png image file of the output in the current directory. |
| `localPreviewPath` | `current directory` | String | Path to create example files. MacOS, Linux and Windows paths supported. |
| `debug` | `false` | Boolean | If enabled, it will show messages in the console during code execution. |
## Examples
### Default output
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo()
```
[](https://npmjs.com/package/rayso-api)
### Custom parameters
```javascript
import RaySo, {
CardTheme,
CardPadding,
CardProgrammingLanguage,
} from 'rayso-api'
const raySo = new RaySo({
title: 'Custom Title',
theme: CardTheme.CANDY,
padding: CardPadding.md,
language: CardProgrammingLanguage.JS,
debug: true,
localPreview: true,
localPreviewPath: '/Users/s0ftik3/rayso_screenshots',
})
```
[](https://npmjs.com/package/rayso-api)
### Output without background
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ background: false })
```
[](https://npmjs.com/package/rayso-api)
## Themes
These are all the available themes, so far. As soon Ray.So has a new theme, it will appear here. Default theme `breeze` is not listed here, you saw it in the first picture of this README.
### Candy
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'candy' })
```
[](https://npmjs.com/package/rayso-api)
### Crimson
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'crimson' })
```
[](https://npmjs.com/package/rayso-api)
### Falcon
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'falcon' })
```
[](https://npmjs.com/package/rayso-api)
### Meadow
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'meadow' })
```
[](https://npmjs.com/package/rayso-api)
### Midnight
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'midnight' })
```
[](https://npmjs.com/package/rayso-api)
### Raindrop
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'raindrop' })
```
[](https://npmjs.com/package/rayso-api)
### Sunset
```javascript
import RaySo from 'rayso-api'
const raySo = new RaySo({ theme: 'sunset' })
```
[](https://npmjs.com/package/rayso-api)
## Credits
- The source is [ray.so](https://ray.so) website.