API
Call Datarist directly over REST or GraphQL: base URLs, API keys, SDKs, errors and rate limits, and the OpenAPI and GraphQL schema documentation.
Everything the CLI and the SDKs do goes through the Datarist API. You can call it directly from any language that can make HTTPS requests, over REST or GraphQL. Both use the same API keys and return the same data.
Placeholder content. The URLs, package names and responses on this page show the shape of the API documentation. They are examples until the platform is released.
Choose an interface
| Detail | REST | GraphQL |
|---|---|---|
| Base URL | https://api.datarist.com/v1 | https://api.datarist.com/graphql |
| Best for | Simple requests, scripts, and tools that already speak HTTP. | Fetching exactly the fields you need, across several resources, in one request. |
| Authentication | API key in the Authorization header. | The same API key, the same header. |
| Schema | OpenAPI document. | Introspection and a schema file. |
API keys
Send an API key as a bearer token in the Authorization header. Create and revoke keys in your workspace settings. A key belongs to one workspace and carries the permissions of the role it was created with.
- Use a separate key for each application, so that you can revoke one without affecting the others.
- Store keys in an environment variable such as
DATARIST_API_KEY, which the SDKs and the CLI read by default. - To rotate a key, create the new one, deploy it, then revoke the old one.
- A request without a valid key gets a
401response.
Keep keys secret. Never put an API key in client-side code, a public repository or a support request. If a key is exposed, revoke it straight away and create a new one.
REST
Make a request
List the first two rows of the orders dataset:
curl "https://api.datarist.com/v1/datasets/orders/rows?limit=2" \
--header "Authorization: Bearer $DATARIST_API_KEY"Responses are JSON. When there is more data, next holds a cursor to pass back as ?cursor=; it is null on the last page.
{
"data": [
{ "order_id": "O000001", "customer_id": "C00378", "order_date": "2024-02-28", "currency": "GBP", "amount": 109.5, "status": "paid" },
{ "order_id": "O000002", "customer_id": "C00197", "order_date": "2024-03-23", "currency": "EUR", "amount": 101.12, "status": "pending" }
],
"next": "cur_8f3a2c"
}Resources
| Resource | URL | Methods |
|---|---|---|
| Sources | https://api.datarist.com/v1/sources | GET, POST, DELETE |
| Datasets | https://api.datarist.com/v1/datasets | GET |
| Rows of a dataset | https://api.datarist.com/v1/datasets/{name}/rows | GET |
| Schema of a dataset | https://api.datarist.com/v1/datasets/{name}/schema | GET |
| Syncs | https://api.datarist.com/v1/syncs | GET, POST |
Versioning
The version is part of the URL (/v1). Changes that could break a client, such as removing a field, ship in a new version. Additive changes, such as a new field or a new resource, ship in the current one. Every change to the API is listed in the Changelog.
GraphQL
Send queries as a POST to https://api.datarist.com/graphql, with the same Authorization header. Ask for the fields you need and nothing else:
query {
dataset(name: "orders") {
rows(limit: 2) {
order_id
currency
amount
}
}
}curl https://api.datarist.com/graphql \
--header "Authorization: Bearer $DATARIST_API_KEY" \
--header "Content-Type: application/json" \
--data '{"query": "{ dataset(name: \"orders\") { rows(limit: 2) { order_id amount } } }"}'GraphQL always answers with status 200 when the request reached the server. Check the errors array in the body, which is absent when the query succeeded.
Errors and rate limits
REST errors use a conventional status code and a JSON body. Quote the request_id when you contact support.
{
"error": {
"code": "unauthorized",
"message": "The API key is missing or not valid.",
"request_id": "req_41d9b7"
}
}| Status | Meaning | What to do |
|---|---|---|
400 | The request is malformed. | Fix the request. Do not retry it unchanged. |
401 | The API key is missing or not valid. | Check the key and the Authorization header. |
403 | The key’s role does not allow this. | Use a key with the right role. |
404 | The resource does not exist. | Check the name or id. |
429 | Too many requests. | Wait for the time in the Retry-After header, then retry. |
5xx | Something went wrong on our side. | Retry with a growing delay. Check Status. |
Limits depend on your plan. Responses carry RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset headers, so a client can slow down before it is refused.
SDKs
The SDKs wrap the API, read DATARIST_API_KEY for you and handle pagination and retries. They offer the same operations in each language’s own idioms. See Install for first steps in each one.
| Language | Package | Install |
|---|---|---|
| JavaScript and TypeScript | @datarist/sdk | npm install @datarist/sdk |
| Python | datarist | pip install datarist |
| .NET | Datarist | dotnet add package Datarist |
| Go | github.com/datarist/datarist-go | go get github.com/datarist/datarist-go |
| Command line | @datarist/cli | npm install --global @datarist/cli |
Schema documentation
The API describes itself, so that you can generate clients, validate requests and explore it in the tools you already use.
| What | Where |
|---|---|
| REST: OpenAPI 3 document | https://api.datarist.com/v1/openapi.json |
| GraphQL: schema file | https://api.datarist.com/graphql/schema.graphql |
| GraphQL: introspection | Send a standard introspection query to the GraphQL URL. |
| One dataset’s fields | https://api.datarist.com/v1/datasets/{name}/schema |
Dataset schemas
The schema of a dataset is its data dictionary: for every field, the name, the type, whether it can be empty, what it means and an example. It has the same shape as the dictionaries you can download from the Dataset page. For example, for orders (shortened):
{
"dataset": "orders",
"fields": [
{ "name": "order_id", "type": "string", "nullable": false, "allowed_values": null,
"description": "Unique order identifier. Primary key.", "example": "O000001" },
{ "name": "currency", "type": "string", "nullable": false, "allowed_values": ["USD", "EUR", "GBP", "KES"],
"description": "Currency of amount, ISO 4217.", "example": "USD" },
{ "name": "discount_pct", "type": "integer", "nullable": true, "allowed_values": null,
"description": "Discount applied, in whole percent. Empty when none.", "example": "10" }
]
}Types are string, integer, decimal, boolean, date and datetime. The Methodology page explains how dates, empty values and decimals are written.
Next steps
- Make your first call with the Quickstart.
- Read how data is sourced and defined in Methodology.
- Try the API’s response shapes on real files: the sample datasets.
- Questions? Email data@datarist.com or use the Contact page.