Overview

The Databrain API provides endpoints for retrieving dashboards and metrics from data apps in both cloud Databrain and self-hosted Databrain environments.

API Endpoints

Cloud Databrain Endpoint

POST https://api.usedatabrain.com/api/v2/dataApp/dashboards

Self-hosted Databrain Endpoint

POST <SELF_HOSTED_URL>/api/v2/dataApp/dashboards

Headers

Authorization
string
required
Bearer API TOKEN

API Methods

Fetch Dashboards by datapp

Endpoint:
POST /dashboards
Request Body:
{
  "isPagination": "boolean (optional)",
  "pageNumber": "number (optional)",
  "filters":{
	"dashboardNames": ["dashboard name 1", "dashboard name 2"] // string array of dashboard name
	} // (optional)
	
}
Response:
{
  "data": [
    {
      "name": "string",
      "externalDashboardId": "string"
    }
  ],
  "error": null
}
Error Response:
400 -Error
{
  "error": {
    "code": "string",
    "message": "string",
    "status": 400
  }
}

Fetch Metrics by embed and client

Endpoint:
POST /metrics
Request Body:
{
  "embedId": "string",
  "clientId": "string",
  "isPagination": "boolean (optional)",
  "pageNumber": "number (optional)"
}
Response:
{
  "data": [
    {
      "name": "string",
      "metricId": "string"
    }
  ],
  "error": null
}
Error Response:
400 -Error
{
  "error": {
    "code": "string",
    "message": "string",
    "status": 400
  }
}

Error Codes

  • INVALID_DATA_APP_API_KEY: Invalid or missing Data App API Key
  • INVALID_REQUEST_BODY: Required fields missing or wrong type
  • EMBED_PARAM_ERROR: Embed ID not found or mismatched with API Key

Validation Schema

The request body must conform to the following schema:
  • embedid (required): embedId of the data app; embedID .
  • clientid (required): client id.
  • isPagination (optional): Boolean flag to enable pagination.
  • pageNumber (optional): Page number when pagination is enabled.

Example Use Cases

Fetching Dashboards

Request
{
  "isPagination": true,
  "pageNumber": 2
}
Response
{
  "data": [
    {
      "name": "Dashboard 1",
      "externalDashboardId": "12345"
    },
    {
      "name": "Dashboard 2",
      "externalDashboardId": "67890"
    }
  ],
  "error": null
}

Fetch Metrics by embed and client

Endpoint:
POST /metrics
Request Body:
{
  "embedId": "string",
  "clientId": "string",
  "isPagination": "boolean (optional)",
  "pageNumber": "number (optional)"
}
Response:
{
  "data": [
    {
      "name": "string",
      "metricId": "string"
    }
  ],
  "error": null
}
Error Response:
400 -Error
{
  "error": {
    "code": "string",
    "message": "string",
    "status": 400
  }
}

Error Codes

  • INVALID_DATA_APP_API_KEY: Invalid or missing Data App API Key
  • INVALID_REQUEST_BODY: Required fields missing or wrong type
  • EMBED_PARAM_ERROR: Embed ID not found or mismatched with API Key

Validation Schema

The request body must conform to the following schema:
  • embedId (required): embedId of the data app; embedID
  • clientId (required): client id.
  • isPagination (optional): Boolean flag to enable pagination.
  • pageNumber (optional): Page number when pagination is enabled.

Example Use Cases

Fetching Metrics by embed Id and client

Request:
{
  "embedId": "FinanceWorkspace",
  "clientId": "98765",
  "isPagination": true,
  "pageNumber": 1
}
Response:
{
  "data": [
    {
      "name": "Revenue Metric",
      "metricId": "r123"
    },
    {
      "name": "Expense Metric",
      "metricId": "e456"
    }
  ],
  "error": null
}

Query Metric API

Fetch Metrics by embed and client

Endpoint:
POST /api/v2/dataApp/query
Step 1 : Create an embedded metric dataapp copy the embedId
Step 2 : Create an API token from the same embedded metric
Step 3 : Authorization string required Request Body:
{
     ​​"embedId": <string>, // required * 
    "metricId": <string>, // required * 
    "clientId": <string>, // required *
    "datasourceName": <string>, // if workspace is multidatasource
    "dashboardFilter": {},  // copy the object value of globalFilters
    “metricFilter”: [] // copy object value of rlsConditions
}

**Response:**

```json
{"data":[{},{}],"timeTaken":106,"metaData":{"groupbyColumnList":[]}}

Error Codes

  • INVALID_DATA_APP_API_KEY: Invalid or missing Data App API Key
  • INVALID_REQUEST_BODY: Required fields missing or wrong type
  • EMBED_PARAM_ERROR: Embed ID not found or mismatched with API Key
Examples