Skip to Content

Data Retrieval

Preview a chart

Draw rows you already have as a Databrain chart (SVG), without saving a metric.

POST
/api/v2/data-app/chart-preview

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.

Authorization

ServiceToken
headerAuthorizationBearer <token>

A service token. A data app API token is refused.

Body

rowsobject[]required

The rows to draw. A JSON string of the array also works.

chartTypestringrequired

The chart type, for example line, 1 to 80 characters.

titlestring

Up to 500 characters.

Default: ""
xAxisstring

Column for the x axis.

yAxisstring[]

Columns for the y axis, up to 10.

Column that splits the series.

Column for a single-value chart.

dimensionsstring[]

Up to 20 each.

Default: []
measuresstring[]

Up to 20 each.

Default: []
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>"}
FieldDescription
kindchart, kpi or table
svgThe chart as an SVG string. Put it in your page as is
valueFor a kpi: the single value
rows, columnsThe rows that were drawn

Errors

Statuserror.codeWhy
400INVALID_PREVIEW_REQUESTA field is missing or out of range
400INVALID_CHART_CONFIGThe columns do not fit the chart type
403AUTHENTICATION_ERRORYou used a data app API token
429Over 120 requests a minute
503CHART_UNAVAILABLEThe chart could not be drawn. Try again

For errors that every endpoint returns, see Authentication.

Example Request
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>"}