Skip to Content

Datasource APIs

Get a datasource schema

List the tables and columns of one connected datasource.

GET
/api/v2/datasource/schema

Use it to pick the tables and columns for a datamart. It reads the schema from the datasource and changes nothing.

curl "https://api.usedatabrain.com/api/v2/datasource/schema?datasourceName=Sales%20warehouse" \  --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN"

Auth

A service token only. A data app API token gets 403. See Authentication.

Limits

10 requests in 5 minutes per organization, shared with create, update and sync. The whole schema comes in one response, with no pages.

Authorization

ServiceToken
headerAuthorizationBearer <token>

A service token. A data app API token is refused.

Query

datasourceNamestringrequired

The datasource name, exactly as saved.

Response

{  "data": {    "datasourceName": "Sales warehouse",    "datasourceId": "6f1c2b9e-4d3a-4f8e-9b7c-2a1d0e5f6c7b",    "tables": [      {        "name": "orders",        "schema": "public",        "columns": [          { "name": "id", "dataType": "integer" },          { "name": "created_at", "dataType": "timestamp" }        ]      }    ],    "tableCount": 1,    "columnCount": 2  }}

System schemas (information_schema, pg_catalog, mysql, performance_schema, sys, system) are left out. dataType is unknown when the datasource does not report a type. Relationships are not returned.

Errors

Statuserror.codeWhy
400INVALID_REQUEST_BODYdatasourceName is missing
400DATASOURCE_NAME_ERRORNo datasource has this name, it is turned off, or its connection test failed
403AUTHENTICATION_ERRORYou used a data app API token
429Rate limit
500INTERNAL_SERVER_ERRORDatabrain could not read the schema

For errors that every endpoint returns, see Authentication.

Example Request
curl -X GET 'https://api.usedatabrain.com/api/v2/datasource/schema?datasourceName=string'
Example Response
{  "data": {    "datasourceName": "Sales warehouse",    "datasourceId": "6f1c2b9e-4d3a-4f8e-9b7c-2a1d0e5f6c7b",    "tables": [      {        "name": "orders",        "schema": "public",        "columns": [          {            "name": "id",            "dataType": "integer"          },          {            "name": "created_at",            "dataType": "timestamp"          }        ]      }    ],    "tableCount": 1,    "columnCount": 2  }}