Data Retrieval
Preview a chart
Draw rows you already have as a Databrain chart (SVG), without saving a metric.
POST
Use it to show the answer of Ask a question as a chart. Nothing is saved and no query runs: you send the rows.
curl --request POST https://api.usedatabrain.com/api/v2/data-app/chart-preview \ --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "chartType": "line", "title": "Revenue by month", "xAxis": "month", "yAxis": ["revenue"], "rows": [{ "month": "2026-10", "revenue": 182340 }, { "month": "2026-11", "revenue": 194112 }] }'Auth
A service token only. See Authentication.
Limits
120 requests a minute per token.
ServiceTokenheader
AuthorizationBearer <token>A service token. A data app API token is refused.
Body
The rows to draw. A JSON string of the array also works.
The chart type, for example line, 1 to 80 characters.
xAxisstring
Column for the x axis.
yAxisstring[]
Columns for the y axis, up to 10.
seriesFieldstring
Column that splits the series.
singleValuestring
Column for a single-value chart.
widthinteger
240 to 1200. Default 600
heightinteger
120 to 800. Default 320
Response
{ "kind": "chart", "title": "Revenue by month", "chartSpec": { "type": "line" }, "columns": ["month", "revenue"], "rows": [{ "month": "2026-10", "revenue": 182340 }, { "month": "2026-11", "revenue": 194112 }], "width": 600, "height": 320, "points": [], "svg": "<svg ...>...</svg>"}| Field | Description |
|---|---|
kind | chart, kpi or table |
svg | The chart as an SVG string. Put it in your page as is |
value | For a kpi: the single value |
rows, columns | The rows that were drawn |
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_PREVIEW_REQUEST | A field is missing or out of range |
| 400 | INVALID_CHART_CONFIG | The columns do not fit the chart type |
| 403 | AUTHENTICATION_ERROR | You used a data app API token |
| 429 | Over 120 requests a minute | |
| 503 | CHART_UNAVAILABLE | The chart could not be drawn. Try again |
For errors that every endpoint returns, see Authentication.
curl -X POST 'https://api.usedatabrain.com/api/v2/data-app/chart-preview' \ -H 'Content-Type: application/json' \ -d '{ "chartType": "line", "title": "Revenue by month", "xAxis": "month", "yAxis": [ "revenue" ], "rows": [ { "month": "2026-10", "revenue": 182340 }, { "month": "2026-11", "revenue": 194112 } ]}'Example Response
{ "kind": "chart", "title": "Revenue by month", "chartSpec": { "type": "line" }, "columns": [ "month", "revenue" ], "rows": [ { "month": "2026-10", "revenue": 182340 }, { "month": "2026-11", "revenue": 194112 } ], "width": 600, "height": 320, "points": [], "svg": "<svg ...>...</svg>"}