curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789",
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
}
},
"metricFilter": {
"region": "north-america"
}
}'
{
"data": [
{
"date": "2024-01-01",
"revenue": 15000,
"region": "north-america",
"customer_count": 45
},
{
"date": "2024-01-02",
"revenue": 18500,
"region": "north-america",
"customer_count": 52
},
{
"date": "2024-01-03",
"revenue": 16500,
"region": "north-america",
"customer_count": 138
}
],
"timeTaken": 245,
"comparisonValue": 12500,
"totalRecords": 31,
"metaData": {
"columns": [
{
"name": "date",
"dataType": "date"
},
{
"name": "revenue",
"dataType": "number"
},
{
"name": "region",
"dataType": "string"
},
{
"name": "customer_count",
"dataType": "number"
}
],
"groupbyColumnList": ["date", "region"]
},
"metricid": "metric_456",
"error": null
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789",
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
}
},
"metricFilter": {
"region": "north-america"
}
}'
{
"data": [
{
"date": "2024-01-01",
"revenue": 15000,
"region": "north-america",
"customer_count": 45
},
{
"date": "2024-01-02",
"revenue": 18500,
"region": "north-america",
"customer_count": 52
},
{
"date": "2024-01-03",
"revenue": 16500,
"region": "north-america",
"customer_count": 138
}
],
"timeTaken": 245,
"comparisonValue": 12500,
"totalRecords": 31,
"metaData": {
"columns": [
{
"name": "date",
"dataType": "date"
},
{
"name": "revenue",
"dataType": "number"
},
{
"name": "region",
"dataType": "string"
},
{
"name": "customer_count",
"dataType": "number"
}
],
"groupbyColumnList": ["date", "region"]
},
"metricid": "metric_456",
"error": null
}
Execute queries on metrics within your embedded dashboards and retrieve the resulting data.
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789",
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
}
},
"metricFilter": {
"region": "north-america"
}
}'
{
"data": [
{
"date": "2024-01-01",
"revenue": 15000,
"region": "north-america",
"customer_count": 45
},
{
"date": "2024-01-02",
"revenue": 18500,
"region": "north-america",
"customer_count": 52
},
{
"date": "2024-01-03",
"revenue": 16500,
"region": "north-america",
"customer_count": 138
}
],
"timeTaken": 245,
"comparisonValue": 12500,
"totalRecords": 31,
"metaData": {
"columns": [
{
"name": "date",
"dataType": "date"
},
{
"name": "revenue",
"dataType": "number"
},
{
"name": "region",
"dataType": "string"
},
{
"name": "customer_count",
"dataType": "number"
}
],
"groupbyColumnList": ["date", "region"]
},
"metricid": "metric_456",
"error": null
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789",
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
}
},
"metricFilter": {
"region": "north-america"
}
}'
{
"data": [
{
"date": "2024-01-01",
"revenue": 15000,
"region": "north-america",
"customer_count": 45
},
{
"date": "2024-01-02",
"revenue": 18500,
"region": "north-america",
"customer_count": 52
},
{
"date": "2024-01-03",
"revenue": 16500,
"region": "north-america",
"customer_count": 138
}
],
"timeTaken": 245,
"comparisonValue": 12500,
"totalRecords": 31,
"metaData": {
"columns": [
{
"name": "date",
"dataType": "date"
},
{
"name": "revenue",
"dataType": "number"
},
{
"name": "region",
"dataType": "string"
},
{
"name": "customer_count",
"dataType": "number"
}
],
"groupbyColumnList": ["date", "region"]
},
"metricid": "metric_456",
"error": null
}
/api/v2/data-app/query. The old endpoint /api/v2/dataApp/query will be deprecated soon. Please update your integrations to use the new endpoint format.POST https://api.usedatabrain.com/api/v2/data-app/query
POST https://api.usedatabrain.com/api/v2/dataApp/query
Authorization: Bearer dbn_live_abc123...
application/json for all requests.Content-Type: application/json
Show Finding embed IDs
Show Finding metric IDs
/metric/{metricId}Show Client ID usage
Show Dashboard filter examples
{
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
},
"region": "north-america",
"product_category": "electronics"
}
Show Metric filter examples
{
"customer_segment": "enterprise",
"product_category": "software",
"status": "active"
}
MULTI_DATASOURCE): pass the datasource name (as in Data Studio / your integration credentials) so the query runs against that datasource. If the name does not resolve, the API returns DATASOURCE_NAME_ERROR (400).Show Details
dataMartName instead when applicabledataMartName (camelCase with a capital M in Mart).When the dashboard’s workspace is configured for multiple datamarts (MULTI_DATAMART), pass the datamart name so the query resolves that datamart’s linked datasource. Names follow the same rules as in the List Datamarts API. If the name does not resolve, the API returns DATAMART_NAME_ERROR (400).Show Details
datasourceName instead when applicabledatamartName (different casing for this endpoint)[
{
"date": "2024-01-01",
"revenue": 15000,
"region": "north-america"
},
{
"date": "2024-01-02",
"revenue": 18000,
"region": "north-america"
}
]
null for successful requests.dataMartName could not be resolved for a multi-datamart workspace| Status Code | Description |
|---|---|
200 | OK - Query executed successfully |
400 | Bad Request - Invalid request parameters or missing required fields |
401 | Unauthorized - Invalid or expired API token |
404 | Not Found - Embed ID or metric ID not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Unexpected server error |
| Error Code | HTTP Status | Description |
|---|---|---|
INVALID_EMBED_ID | 400 | Embed ID not found |
INVALID_METRIC_ID | 400 | Invalid metric ID |
INVALID_DATA_APP_API_KEY | 401 | Missing or invalid data app |
EMBED_PARAM_ERROR | 404 | Embed ID error |
METRIC_NOT_FOUND | 404 | Metric not found |
DATASOURCE_NAME_ERROR | 400 | Invalid datasource name (multi-datasource) |
DATAMART_NAME_ERROR | 400 | Invalid datamart name (multi-datamart) |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
INTERNAL_SERVER_ERROR | 500 | Unexpected failure |
{
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-03-31"
},
"region": "north-america",
"product_category": "electronics"
}
}
{
"metricFilter": {
"department": "sales",
"status": "active",
"client_group": "enterprise"
}
}
async function exportDashboardData(embedId, clientId) {
// Get all metrics
const metricsResponse = await fetch(
`https://api.usedatabrain.com/api/v2/data-app/metrics?embedId=${embedId}&clientId=${clientId}`,
{
headers: { 'Authorization': 'Bearer dbn_live_...' }
}
);
const { data: metrics } = await metricsResponse.json();
// Query each metric
const allData = {};
for (const metric of metrics) {
const queryResponse = await fetch(
'https://api.usedatabrain.com/api/v2/data-app/query',
{
method: 'POST',
headers: {
'Authorization': 'Bearer dbn_live_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
embedId,
metricId: metric.metricId,
clientId
})
}
);
const queryResult = await queryResponse.json();
allData[metric.name] = queryResult.data;
}
return allData;
}
async function refreshMetricData(embedId, metricId, clientId, filters) {
const response = await fetch(
'https://api.usedatabrain.com/api/v2/data-app/query',
{
method: 'POST',
headers: {
'Authorization': 'Bearer dbn_live_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
embedId,
metricId,
clientId,
dashboardFilter: filters
})
}
);
return await response.json();
}
// Refresh every 5 minutes
setInterval(async () => {
const data = await refreshMetricData(
'embed_123',
'metric_456',
'user_789',
{ date_range: { start: 'today', end: 'today' } }
);
updateDashboard(data);
}, 5 * 60 * 1000);
async function getClientMetricData(embedId, metricId, clientId) {
// Apply client-specific filters automatically
const response = await fetch(
'https://api.usedatabrain.com/api/v2/data-app/query',
{
method: 'POST',
headers: {
'Authorization': 'Bearer dbn_live_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
embedId,
metricId,
clientId,
metricFilter: {
// RLS ensures clients only see their data
client_id: clientId
}
})
}
);
return await response.json();
}
Get embed and metric IDs
# List your embeds to find the embedId
curl --request GET \
--url https://api.usedatabrain.com/api/v2/data-app/embeds \
--header 'Authorization: Bearer dbn_live_abc123...'
Fetch available metrics
curl --request GET \
--url 'https://api.usedatabrain.com/api/v2/data-app/metrics?embedId=embed_123&clientId=user_789' \
--header 'Authorization: Bearer dbn_live_abc123...'
Make your first query
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789"
}'
Add filters for specific data
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/query \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"embedId": "embed_123",
"metricId": "metric_456",
"clientId": "user_789",
"dashboardFilter": {
"date_range": {
"start": "2024-01-01",
"end": "2024-01-31"
}
}
}'
Process the results
const queryData = await queryMetric({
embedId: 'embed_123',
metricId: 'metric_456',
clientId: 'user_789'
});
console.log(`Found ${queryData.totalRecords} records`);
console.log(`Query took ${queryData.timeTaken}ms`);
queryData.data.forEach(row => {
// Process each data row
console.log(row);
});