Chart Image API
Render bar, line, area, pie, doughnut, scatter and sparkline charts from a Chart.js-like JSON config as PNG or SVG, by a URL usable in <img> and emails.
Describe the chart in JSON and get an image: {"type":"bar","data":{"labels":[…],"datasets":[{"label":"…","data":[…]}]},"options":{"title":"…"}}. Types: bar, horizontal-bar (or Chart.js indexAxis: "y"), line, area, pie, doughnut, scatter (points {x, y}) and sparkline. Several datasets are grouped (or stacked: true), a dataset of a bar chart can be drawn as a line, gaps (null) break lines, and tension smooths them. Options: title, subtitle, legend (top, bottom, right, false), x_label / y_label, min / max, values (data labels), prefix / suffix (" ₫", "%"), locale (vi writes 1.234,5 and 12 tr / 3 tỷ on axes), theme (light / dark), font_size and colours per dataset (color, backgroundColor, an array for one colour per bar). The usual Chart.js keys (plugins.title, plugins.legend, scales.y.min, scales.x.stacked…) are understood, so most QuickChart-style configs work as they are.
Because it answers GET with the config URL-encoded in c, the URL can be put straight into <img src>, an e-mail, a Slack / Zalo message or a Markdown / PDF report. PNG (default) and JPEG are drawn by our own renderer with the Be Vietnam Pro font, so Vietnamese text looks the same everywhere; scale=2 gives a sharp image on retina screens. SVG keeps the text as vector outlines by default (exact rendering without fonts), svg_text=text writes real <text> elements instead.
Size: width × height up to 2000 px and 4 megapixels with scale, up to 20 datasets and 10,000 points. The colours follow a colour-blind-checked palette; the renderer is our own code (not QuickChart or Chart.js).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
c | query|body | object | yes | Chart config (JSON; URL-encoded in GET): type, data.labels, data.datasets, options. chart is an alias. | |
format | query|body | string | no | png | png, svg, jpeg or json (PNG as base64 + SVG). |
width | query|body | number | no | 600 | Width in pixels (50–2000). |
height | query|body | number | no | 400 | Height in pixels (30–2000). |
scale | query|body | number | no | 1 | Pixel ratio of PNG / JPEG (1–4), e.g. 2 for retina screens. |
theme | query|body | string | no | light | light or dark (also options.theme). |
locale | query|body | string | no | en | vi for Vietnamese number format (1.234,5; 12 tr; 3 tỷ). |
background | query|body | string | no | Background colour (#fff, transparent…). | |
svg_text | query|body | string | no | paths | SVG only: paths (text as outlines) or text (<text> elements). |
Example
curl "https://apibox.io.vn/v1/chart-image?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22T1%22%2C%22T2%22%2C%22T3%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Doanh%20thu%22%2C%22data%22%3A%5B12%2C19%2C7%5D%7D%5D%7D%7D" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o outputconst res = await fetch('https://apibox.io.vn/v1/chart-image?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22T1%22%2C%22T2%22%2C%22T3%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Doanh%20thu%22%2C%22data%22%3A%5B12%2C19%2C7%5D%7D%5D%7D%7D', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const blob = await res.blob();import requests
res = requests.get(
"https://apibox.io.vn/v1/chart-image?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22T1%22%2C%22T2%22%2C%22T3%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Doanh%20thu%22%2C%22data%22%3A%5B12%2C19%2C7%5D%7D%5D%7D%7D",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
open("output", "wb").write(res.content)<?php
$ch = curl_init('https://apibox.io.vn/v1/chart-image?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22T1%22%2C%22T2%22%2C%22T3%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Doanh%20thu%22%2C%22data%22%3A%5B12%2C19%2C7%5D%7D%5D%7D%7D');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
file_put_contents('output', $response);Response
binary image/png
Use cases
- Charts in daily report e-mails (sales, traffic, orders)
- Images for Slack, Zalo or Telegram bot messages
- Charts inside generated PDFs and Markdown reports
- Sparklines and KPI images in dashboards without a JS library
FAQ
Can I use it in an <img> tag?
Yes: GET /v1/chart-image?c=<URL-encoded JSON>&api_key=… returns the PNG directly. Keep long configs in POST.
Is it compatible with Chart.js / QuickChart configs?
The common parts are: type, data.labels, datasets (label, data, backgroundColor, borderColor, fill, tension, type), indexAxis, plugins.title / legend, scales min / max / stacked.
Does Vietnamese text render correctly?
Yes, PNG and SVG draw text from the Be Vietnam Pro outlines, so diacritics are exact without any installed font.
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
|||Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.