Data Retrieval
Fetch metric data by data app
Execute queries on metrics within your embedded dashboards and retrieve the resulting data.
POST
Query specific metrics from your embedded dashboards to retrieve data programmatically. This endpoint allows you to fetch metric data with optional filtering and is essential for building custom analytics interfaces or exporting data from your embedded dashboards.Documentation Index
Fetch the complete documentation index at: https://docs.usedatabrain.com/llms.txt
Use this file to discover all available pages before exploring further.
This endpoint requires an embed ID, metric ID, and client ID. The metric must be associated with the specified embed configuration for the query to succeed.
Endpoint Formats
- New Endpoint (Recommended)
- Legacy Endpoint (Deprecated Soon)
Authentication
All API requests must include your API key in the Authorization header. Get your API token when creating a data app - see our data app creation guide for details. Finding your API token: For detailed instructions, see the API Token guide.Headers
Bearer token for API authentication. Use your API key from the data app.
Must be set to
application/json for all requests.Request Body
The unique identifier of the embed configuration containing the metric.
The unique identifier of the metric to query.
Unique identifier for the end user making the query. Used for row-level security and access control.
Dashboard-level filters to apply to the metric query. These filters affect the entire dashboard context.
Metric-specific filters to apply to the query. Used for row-level security and additional filtering.
Optional string. Use when the dashboard’s workspace is configured for multiple datasources (
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).Optional string. Use the exact JSON property name
dataMartName (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).Response
Array of objects containing the query results. Each object represents a row of data with column names as keys.
Example
Query execution time in milliseconds.
Comparison value for metrics with comparison enabled.
Total number of records in the result set.
The metric ID that was queried (echo of request parameter).
Error object if the request failed, otherwise
null for successful requests.Examples
Error Codes
Invalid embed ID - The specified embed ID doesn’t exist or you don’t have access
Invalid metric ID - The specified metric ID doesn’t exist or isn’t associated with the embed
Missing or invalid data app - Check your API key and data app configuration
Embed ID error - The embed ID was not found or doesn’t match the API key being used
Metric not found - The specified metric ID doesn’t exist or isn’t associated with the embed configuration
Invalid datasource name - The specified datasource name could not be resolved for a multi-datasource workspace
Invalid datamart name - The specified
dataMartName could not be resolved for a multi-datamart workspaceHTTP Status Code Summary
| 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 |
Possible Errors
| 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 |
Filtering Guide
Dashboard Filters
Dashboard filters apply to the entire dashboard context and affect all metrics. Common use cases include:- Date range filtering: Limit data to specific time periods
- Category filtering: Filter by region, department, product line, etc.
- Global parameters: Set values that affect multiple metrics
Example
Metric Filters
Metric filters apply specifically to the metric being queried and can be used for:- Row-level security (RLS): Restrict data based on client permissions
- Additional filtering: Apply metric-specific conditions
- Client isolation: Ensure multi-tenant data separation
Example
Use Cases
Export Dashboard Data
Real-time Data Refresh
Multi-Tenant Data Access
Best Practices
- Cache responses - Cache query results when appropriate to reduce API calls and improve performance
- Use filters efficiently - Apply filters at the query level rather than filtering data client-side
- Handle pagination - For large datasets, implement pagination or limit results
- Error handling - Implement robust error handling and retry logic
- Rate limiting - Respect rate limits and implement exponential backoff
- Security - Never expose API keys in client-side code; proxy requests through your backend
Performance Tips
- Minimize filter complexity - Complex filters can slow down queries
- Request only needed columns - If possible, select only required columns
- Use date ranges - Limit queries to specific time periods
- Cache when possible - Cache frequently accessed data
- Batch requests - When querying multiple metrics, consider batching requests
Quick Start Guide
Get embed and metric IDs
First, get your embed ID and metric ID from your DataBrain dashboard or via the List APIs:
Fetch available metrics
Use the Fetch Metrics by Embed endpoint to get a list of available metrics:
Next Steps
Fetch Metrics by Embed
Get a list of available metrics before querying
Fetch Dashboards by Data App
Retrieve available dashboards in your data app
Embed a Pre-built Dashboard/Metric
Set up embed configurations for your data app
Guest Token API
Generate secure tokens for embedded access

