Skip to navigation

Query data with SQL

View as Markdown

Execute a read-only SQL query.

Runs the query as PostgreSQL against the organization’s read replica, so it cannot mutate data. Only SELECT statements are accepted. Supports positional parameters: write %s placeholders in the query and pass the values in order in the params list. Named :param placeholders belong to saved dataset queries and are not accepted here. Use the schema tool to discover tables first, and reference each column by its sql_column_name — foreign keys carry an _id suffix in SQL (e.g. a ‘sample’ reference is the ‘sample_id’ column).

A query is cancelled after 90 seconds. At most 10,000 rows are returned, and truncated is true when the query produced more. Aggregate, filter, or page with LIMIT and OFFSET to keep a result within that.

Requires an API key with the read scope.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
querystringRequired
paramslist of any or nullOptional

Response

OK
columnslist of strings
datalist of lists of any
truncatedboolean
Whether the query produced more rows than were returned. Aggregate, filter, or page with LIMIT and OFFSET to read the rest.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
422
Unprocessable Entity Error
500
Internal Server Error
503
Service Unavailable Error