Data Retrieval
Preview a chart
Draw rows you already have as a Databrain chart (SVG), without saving a metric.
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.
- Up to 1,000 rows, 20 columns, and 2,000,000 characters of row data. A column name has up to 128 characters. A cell is text (up to 2,000 characters), a finite number,
true,falseornull. - A bar, line, area, combo, pie or doughnut chart draws up to 50 points: categories times series.
ServiceTokenAuthorizationBearer <token>A service token. A data app API token is refused.
Body
The body is validated strictly: an unknown field returns 400 INVALID_PREVIEW_REQUEST.
The rows to draw. A JSON string of the array also works.
The chart type, 1 to 80 characters. The preview draws bar, row, line, area, stepped, time series, stack, stacked area, horizontal stack, combo, vertical combo, pie, doughnut, single value, table and the pivot types. Gauge and progress charts are not drawn: they return 400 INVALID_CHART_CONFIG.
Column for the x axis. Default: the first dimensions entry. A chart with axes, and a pie or doughnut, needs one of the two.
Columns for the y axis, up to 10. Default: measures. A chart with axes needs one of the two. A pie or doughnut takes exactly one.
Column that splits the series. Default: the second dimensions entry. It is used only when there is one y-axis column. A combo chart, a pie and a doughnut refuse it with 400 UNSUPPORTED_CHART_CONFIG.
Column for a single value chart. Default: the first measures entry. A single value chart needs one of the two.
Up to 20. The dimensions of an Ask a question answer. They give the defaults for xAxis and seriesField.
[]Up to 20. The measures of an Ask a question answer. They give the defaults for yAxis and singleValue.
[]240 to 1200. Default 600
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
A chart error has only error.code, with no message: { "error": { "code": "INVALID_CHART_CONFIG" } }.
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_PREVIEW_REQUEST | A field is missing, unknown or out of range |
| 400 | INVALID_CHART_CONFIG | The columns do not fit the chart type, a column is not in the rows, or the type is a gauge or progress chart |
| 400 | UNSUPPORTED_CHART_TYPE | The preview cannot draw this chartType |
| 400 | UNSUPPORTED_CHART_CONFIG | A combo chart with seriesField, or a pie or doughnut with more than one y-axis column or a seriesField |
| 400 | INVALID_CHART_VALUE | A measure cell is not a number |
| 400 | INVALID_PIE_VALUES | A pie or doughnut value is empty or below zero |
| 403 | AUTHENTICATION_ERROR | You used a data app API token |
| 413 | CHART_DATA_TOO_LARGE | Over the row, column or size limits above |
| 413 | UNSUPPORTED_CHART_CELL | A cell is an object, an array, a number that is not finite, or text over 2,000 characters |
| 413 | TOO_MANY_CHART_POINTS | The chart has more than 50 points |
| 413 | CHART_PAGE_TOO_LARGE | The drawn chart is too large to send |
| 429 | Over 120 requests a minute. The body is plain text | |
| 503 | INVALID_QUERY_RESULT | rows is not a list of objects, or the text is not JSON |
| 503 | CHART_UNAVAILABLE or CHART_RENDERER_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 } ]}'{ "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>"}