JSON a gráfico
JSON a gráfico es una API que convierte datos en una imagen de gráfico (barras, líneas, tarta, donut o radar). Le mandas tus números en JSON y te devuelve una imagen lista para meter en un email, un informe o un mensaje de Slack, sin diseñar nada a mano.
Cómo funciona
Le mandas el tipo de gráfico, las etiquetas (categorías del eje X, o nombres de cada porción) y una o varias series de números, y te devuelve la imagen ya generada — por defecto en PNG, dentro de una respuesta JSON en base64.
Como la entrada siempre es una estructura de datos, esta herramienta solo admite el cuerpo en JSON (no hay modo "pega el archivo a pelo").
Lo único que necesitas
- Tu API key. La creas en tu panel con "+ Crear llave". Se muestra una sola vez, así que cópiala y guárdala.
- En tu plataforma de automatización, un paso de tipo "HTTP Request" / "Hacer una petición HTTP" (lo tienen n8n, Make, Zapier, Pipedream…).
- Tus datos como números — el resto lo hace la herramienta.
Cómo usarlo en n8n (paso a paso)
En el nodo HTTP Request:
- Method:
POST - URL:
https://api.cofferdock.com/chart - Send Headers: actívalo y añade dos:
x-api-key= tu llave, yContent-Type=application/json - Send Body: actívalo → Body Content Type: JSON →
{ "type": "bar", "labels": ["Ene", "Feb", "Mar"], "series": [{ "name": "Ventas", "data": [10, 20, 15] }] }
Por defecto la respuesta ya es un JSON con la imagen en base64 dentro del campo image — no hace falta tocar nada más en Options → Response. Si prefieres recibir la imagen directamente (para adjuntarla como binario), añade "output": "binary" al cuerpo y elige Response Format: File en Options → Response, igual que en otras herramientas de Cofferdock.
En Make (módulo HTTP → Make a request): mismo método y URL, Body type: Raw, Content type: JSON, con el mismo cuerpo.
Opciones (dentro del JSON)
| Opción | Por defecto | Para qué sirve |
|---|---|---|
type | — | Obligatorio. Tipo de gráfico: bar, line, pie, doughnut o radar. |
labels | — | Obligatorio. De 1 a 50 textos: categorías del eje X (barras/líneas) o nombre de cada porción/indicador (tarta/radar). |
series | — | Obligatorio. De 1 a 10 series, cada una { "name": "...", "data": [...] } con tantos números como labels. pie/doughnut solo admiten 1 serie. |
title | — | Título del gráfico (opcional). |
width / height | 800 / 500 | Tamaño en píxeles (entre 200 y 2000). |
format | png | png o svg. |
output | json | json (imagen en base64 dentro de un JSON) o binary (la imagen directamente). |
Resumen de la API
- Endpoint:
POST https://api.cofferdock.com/chart - Auth: cabecera
x-api-key: TU_LLAVE. - Entrada: SOLO
application/json. - Salida: por defecto JSON con la imagen en base64; con
"output": "binary"devuelve la imagen directamente (image/pngoimage/svg+xmlsegúnformat). - Motor: Apache ECharts en modo servidor (sin navegador ni canvas), rasterizado a PNG con
sharpcuando hace falta. - Límites: 30 peticiones/min por IP. 1 gráfico = 1 crédito, sin importar el tipo o el tamaño.
Opciones
| Opción | Por defecto | Descripción |
|---|---|---|
type | — | Obligatorio. bar | line | pie | doughnut | radar (400 si no está en la lista). |
labels | — | Obligatorio. Array de 1 a 50 strings no vacíos, hasta 100 caracteres cada uno. |
series | — | Obligatorio. Array de 1 a 10 objetos { name?, data }. data debe tener el mismo largo que labels y contener solo números finitos. name es opcional (hasta 100 caracteres; si falta, se usa "Series N"). pie/doughnut: 400 si series.length > 1. |
title | — | String opcional, hasta 200 caracteres. |
width / height | 800 / 500 | Número, se ajusta automáticamente al rango [200, 2000]. |
format | png | png o svg. |
output | json | json o binary. |
Ejemplos
curl (gráfico de barras directo a PNG):
curl -X POST "https://api.cofferdock.com/chart" \
-H "x-api-key: TU_LLAVE" \
-H "Content-Type: application/json" \
-d '{"type":"bar","labels":["Ene","Feb","Mar"],"series":[{"name":"Ventas","data":[10,20,15]}],"output":"binary"}' \
-o grafico.png
JavaScript (Node 18+):
const r = await fetch('https://api.cofferdock.com/chart', {
method: 'POST',
headers: { 'x-api-key': 'TU_LLAVE', 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'pie',
title: 'Reparto',
labels: ['A', 'B', 'C'],
series: [{ data: [40, 25, 35] }],
}),
});
const { image } = await r.json();
require('fs').writeFileSync('grafico.png', Buffer.from(image, 'base64'));
Python:
import base64, requests
r = requests.post(
'https://api.cofferdock.com/chart',
headers={'x-api-key': 'TU_LLAVE', 'Content-Type': 'application/json'},
json={'type': 'line', 'labels': ['Ene', 'Feb', 'Mar'], 'series': [{'data': [10, 20, 15]}], 'output': 'binary'},
)
open('grafico.png', 'wb').write(r.content)
Respuesta con output=json (por defecto)
{ "success": true, "image": "iVBORw0KGgoAAAANSUhEUgAA…", "mime_type": "image/png",
"meta": { "format": "png", "width": 800, "height": 500, "used": 12, "remaining": 488 } }
Lo que recibes
Por defecto, un JSON con la imagen en base64 — cómodo para usarla directo en el siguiente paso de tu flujo (por ejemplo, incrustarla en un email como data:image/png;base64,…) sin pasos extra. Con "output": "binary" recibes la imagen directamente, útil si el siguiente paso espera un archivo binario.
JSON to chart
JSON to chart is an API that turns data into a chart image (bar, line, pie, doughnut or radar). Send your numbers as JSON and get back a ready-to-use image for an email, a report or a Slack message, with nothing to design by hand.
How it works
You send the chart type, the labels (X-axis categories, or the name of each slice) and one or more series of numbers, and get back the generated image — PNG by default, base64-encoded inside a JSON response.
Since the input is always a data structure, this tool only accepts a JSON body (there's no "paste the raw file" mode).
All you need
- Your API key. Create it in your dashboard with "+ Create key". It's shown only once, so copy and save it.
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream… all have one).
- Your data as numbers — the tool does the rest.
How to use it in n8n (step by step)
In the HTTP Request node:
- Method:
POST - URL:
https://api.cofferdock.com/chart - Send Headers: on → add two:
x-api-key= your key, andContent-Type=application/json - Send Body: on → Body Content Type: JSON →
{ "type": "bar", "labels": ["Jan", "Feb", "Mar"], "series": [{ "name": "Sales", "data": [10, 20, 15] }] }
By default the response is already a JSON with the image as base64 inside the image field — nothing else to change under Options → Response. If you'd rather get the image directly (to attach it as binary data), add "output": "binary" to the body and choose Response Format: File under Options → Response, same as other Cofferdock tools.
In Make (HTTP → Make a request module): same method and URL, Body type: Raw, Content type: JSON, with the same body.
Options (inside the JSON)
| Option | Default | What it does |
|---|---|---|
type | — | Required. Chart type: bar, line, pie, doughnut or radar. |
labels | — | Required. 1 to 50 strings: X-axis categories (bar/line) or the name of each slice/indicator (pie/radar). |
series | — | Required. 1 to 10 series, each { "name": "...", "data": [...] } with as many numbers as labels. pie/doughnut only support 1 series. |
title | — | Chart title (optional). |
width / height | 800 / 500 | Size in pixels (between 200 and 2000). |
format | png | png or svg. |
output | json | json (base64 image inside a JSON) or binary (the image directly). |
API overview
- Endpoint:
POST https://api.cofferdock.com/chart - Auth: header
x-api-key: YOUR_KEY. - Input:
application/jsonONLY. - Output: JSON with the base64 image by default; with
"output": "binary"it returns the image directly (image/pngorimage/svg+xmldepending onformat). - Engine: Apache ECharts in server mode (no browser, no canvas), rasterized to PNG with
sharpwhen needed. - Limits: 30 requests/min per IP. 1 chart = 1 credit, regardless of type or size.
Options
| Option | Default | Description |
|---|---|---|
type | — | Required. bar | line | pie | doughnut | radar (400 if not in the list). |
labels | — | Required. Array of 1 to 50 non-empty strings, up to 100 characters each. |
series | — | Required. Array of 1 to 10 { name?, data } objects. data must match labels' length and contain only finite numbers. name is optional (up to 100 characters; defaults to "Series N"). pie/doughnut: 400 if series.length > 1. |
title | — | Optional string, up to 200 characters. |
width / height | 800 / 500 | Number, clamped to [200, 2000]. |
format | png | png or svg. |
output | json | json or binary. |
Examples
curl (bar chart straight to PNG):
curl -X POST "https://api.cofferdock.com/chart" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"type":"bar","labels":["Jan","Feb","Mar"],"series":[{"name":"Sales","data":[10,20,15]}],"output":"binary"}' \
-o chart.png
JavaScript (Node 18+):
const r = await fetch('https://api.cofferdock.com/chart', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'pie',
title: 'Breakdown',
labels: ['A', 'B', 'C'],
series: [{ data: [40, 25, 35] }],
}),
});
const { image } = await r.json();
require('fs').writeFileSync('chart.png', Buffer.from(image, 'base64'));
Python:
import base64, requests
r = requests.post(
'https://api.cofferdock.com/chart',
headers={'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json'},
json={'type': 'line', 'labels': ['Jan', 'Feb', 'Mar'], 'series': [{'data': [10, 20, 15]}], 'output': 'binary'},
)
open('chart.png', 'wb').write(r.content)
Response with output=json (default)
{ "success": true, "image": "iVBORw0KGgoAAAANSUhEUgAA…", "mime_type": "image/png",
"meta": { "format": "png", "width": 800, "height": 500, "used": 12, "remaining": 488 } }
What you get back
By default, a JSON with the image as base64 — handy for using it right away in the next step of your flow (for example, embedding it in an email as data:image/png;base64,…) with no extra steps. With "output": "binary" you get the image directly, useful when the next step expects a binary file.