Get a saved analytics chart's data
GET https://api.suger.cloud/ai/org/{orgId}/analytics/chart/{chartId}/data
Runs a saved chart's query and returns its result, read with the caller's own permissions. To a caller who may not read every dataset, a chart that reads a dataset they may not read, or is refused for a reason that might name one, answers NOT_FOUND, as an id no chart has, whoever saved it.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | yes | Organization ID |
chartId | path | string | yes |
Responses
200 — The chart's result
Content-Type: application/json · Schema: AnalyticsQueryResult
AnalyticsQueryResult fields:
| Field | Type | Required | Description |
|---|---|---|---|
schema | object | yes | |
rows | array<object> | yes | One object per row, keyed by the result's column names. |
page | object | no | A records page: `next` is the cursor of the following page, absent on the last one. |
meta | object | yes |
401 — No valid token
Content-Type: application/json · Schema: AiErrorResponse
AiErrorResponse fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | string | yes | Error message |
403 — Not a member of the organization, or DATASET_FORBIDDEN: the query reads a dataset the caller may not read
Content-Type: application/json
404 — NOT_FOUND
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
422 — QUERY_REJECTED, with diagnostics; COST_TOO_HIGH: the query would read too much data
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
429 — BUSY: too many analytics queries are running
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
500 — ANALYTICS_UNAVAILABLE: an unexpected failure
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
503 — ANALYTICS_UNAVAILABLE: analytics is not configured or not ready, or the analytics database failed the query; worth a retry
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
504 — TIMEOUT: the query ran past its time limit
Content-Type: application/json · Schema: AnalyticsError
AnalyticsError fields:
| Field | Type | Required | Description |
|---|---|---|---|
error | object | yes |
Example
Generated from this operation's schema. Values are placeholders —
substitute your own ids, and set SUGER_TOKEN to a bearer token
from the OAuth client-credentials exchange.
Request
curl -X GET 'https://api.suger.cloud/ai/org/{orgId}/analytics/chart/{chartId}/data' \
-H "Authorization: Bearer $SUGER_TOKEN" Response — 200
{
"schema": {
"kind": "aggregate",
"columns": [
{
"name": "Acme Corp",
"role": "dimension",
"label": "string",
"type": {},
"nullable": true,
"approximate": true,
"additive": true,
"time": {
"grain": "day"
},
"change": {
"vs": "previous",
"of": "string",
"as": "delta"
},
"bin": {
"width": 100
}
}
],
"limit": 1,
"order": [
{
"by": "string",
"dir": "asc"
}
]
},
"rows": [
{}
],
"meta": {
"dataVersion": "string",
"asOf": "string",
"truncated": true,
"range": {
"from": "string",
"to": "string"
},
"unbounded": true,
"fxAsOf": "string",
"fxMissing": [
"string"
]
},
"page": {
"next": "string"
}
} Error — 401
{
"error": "string"
} View as Markdown · API reference overview
Spotted something wrong or out of date on this page? Tell us and we'll correct it.