Datasource APIs
Get a datasource schema
List the tables and columns of one connected datasource.
GET
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.
ServiceTokenheader
AuthorizationBearer <token>A service token. A data app API token is refused.
Query
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
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | datasourceName is missing |
| 400 | DATASOURCE_NAME_ERROR | No datasource has this name, it is turned off, or its connection test failed |
| 403 | AUTHENTICATION_ERROR | You used a data app API token |
| 429 | Rate limit | |
| 500 | INTERNAL_SERVER_ERROR | Databrain could not read the schema |
For errors that every endpoint returns, see Authentication.
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 }}