REST API
Generate charts and boards programmatically using the Chartr.ai API.
Base URL: https://chartr.ai
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/v1/charts/types | List available chart types (no auth) |
GET | /api/v1/charts/types/:code | Get JSON schema + example for a chart type (no auth) |
POST | /api/v1/render | Render chart JSON to an image (and optionally save) |
The below endpoints use AI and consume credits:
| Method | Path | Description |
|---|---|---|
POST | /api/v1/boards | Generate a multi-chart board from a prompt |
POST | /api/v1/chart | Generate a single chart from a prompt |
Authentication
All requests require an API key via the X-API-Key header.
Get your API key from Settings.
List Chart Types
List all chart type IDs and labels. No authentication required; useful for discovery and UIs.
GET /api/v1/charts/types
Response
Get Chart Type Schema
Get the JSON schema, validation rules, and an example payload for a chart type. Use with Render Chart to build charts programmatically. No authentication required.
GET /api/v1/charts/types/:code
| Param | Description |
|---|---|
code | Chart type ID (e.g. barChart, timeline, mermaid_flowchart). See List Chart Types. |
Response
Render Chart
Render chart data (JSON) to a PNG image. Use this when you already have chart payloads (e.g. from your own UI or from GET /api/v1/charts/types/:code) and want an image without going through the LLM. Counts against your usage.
POST /api/v1/render
Request
| Parameter | Type | Required | Description |
|---|---|---|---|
chart | object | Yes | Chart payload. Must include code; shape depends on type. Use /api/v1/charts/types/:code for schema + example. |
imageOptions | object | No | Controls what appears in the chart image |
imageOptions.withTitle | boolean | No | Include title and subtitle (default: true) |
imageOptions.withFootnotes | boolean | No | Include footnotes (default: true) |
imageOptions.withBackground | boolean | No | Include background (default: true) |
save | boolean | No | If true, persist chart as a board and return id, url. Default: false. |
Response
Generate Board
Generate a board with one or more charts. Returns the board URL and chart image URLs.
POST /api/v1/boards
Request
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Prompt describing the board to generate |
imageOptions | object | No | Controls what appears in chart images |
imageOptions.withTitle | boolean | No | Include title and subtitle (default: true) |
imageOptions.withFootnotes | boolean | No | Include footnotes (default: true) |
imageOptions.withBackground | boolean | No | Include background (default: true) |
Response
| Field | Type | Description |
|---|---|---|
id | string | Board ID |
url | string | Direct link to the board |
title | string | Generated title |
charts | number | Number of charts created |
imageUrls | string | Image URLs for each chart |
Generate Chart
Generate a single chart. Returns chart data and an image URL.
POST /api/v1/chart
Request
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Prompt describing the chart to generate |
imageOptions | object | No | Controls what appears in the chart image |
imageOptions.withTitle | boolean | No | Include title and subtitle (default: true) |
imageOptions.withFootnotes | boolean | No | Include footnotes (default: true) |
imageOptions.withBackground | boolean | No | Include background (default: true) |
Response
| Field | Type | Description |
|---|---|---|
id | string | Chart ID |
url | string | Direct link to the board |
title | string | Generated title |
chartData | object | Raw chart data |
imageUrl | string | Chart image URL |
Examples
JavaScript
Support
Questions or issues? Contact us at support@chartr.ai