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.
  • 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, false or null.
  • A bar, line, area, combo, pie or doughnut chart draws up to 50 points: categories times series.

Authorization

ServiceToken
headerAuthorizationBearer <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.

rowsobject[]required

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

chartTypestringrequired

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.

titlestring

Up to 500 characters.

Default: ""
xAxisstring

Column for the x axis. Default: the first dimensions entry. A chart with axes, and a pie or doughnut, needs one of the two.

yAxisstring[]

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.

dimensionsstring[]

Up to 20. The dimensions of an Ask a question answer. They give the defaults for xAxis and seriesField.

Default: []
measuresstring[]

Up to 20. The measures of an Ask a question answer. They give the defaults for yAxis and singleValue.

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

A chart error has only error.code, with no message: { "error": { "code": "INVALID_CHART_CONFIG" } }.

Statuserror.codeWhy
400INVALID_PREVIEW_REQUESTA field is missing, unknown or out of range
400INVALID_CHART_CONFIGThe columns do not fit the chart type, a column is not in the rows, or the type is a gauge or progress chart
400UNSUPPORTED_CHART_TYPEThe preview cannot draw this chartType
400UNSUPPORTED_CHART_CONFIGA combo chart with seriesField, or a pie or doughnut with more than one y-axis column or a seriesField
400INVALID_CHART_VALUEA measure cell is not a number
400INVALID_PIE_VALUESA pie or doughnut value is empty or below zero
403AUTHENTICATION_ERRORYou used a data app API token
413CHART_DATA_TOO_LARGEOver the row, column or size limits above
413UNSUPPORTED_CHART_CELLA cell is an object, an array, a number that is not finite, or text over 2,000 characters
413TOO_MANY_CHART_POINTSThe chart has more than 50 points
413CHART_PAGE_TOO_LARGEThe drawn chart is too large to send
429Over 120 requests a minute. The body is plain text
503INVALID_QUERY_RESULTrows is not a list of objects, or the text is not JSON
503CHART_UNAVAILABLE or CHART_RENDERER_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>"}