The
{base_path} part of the endpoint URLs can be configured.
By default, it’s /cubejs-api.{base_path}/v1/load
Run the query to the REST (JSON) API and get the results.
Headers
Response
query- The query passed via params. It can be an array of queries and in such case it will be treated as a Data Blending query.data- Formatted dataset of query results.annotation- Metadata for query. Contains descriptions for all query items.title- Human readable title from the data model.shortTitle- Short title for visualization usage (ex. chart overlay)type- Data type
lastRefreshTime- An ISO 8601 timestamp indicating when the data was last refreshed.external- A boolean indicating whether the query was served from a pre-aggregation in Cube Store. Present only when the query hit a pre-aggregation.total- The total number of rows returned for the query. Useful for paginating results.
{base_path}/v1/sql
Takes an API query and returns the SQL query that can be executed against the data source
that is generated by Cube. This endpoint is useful for debugging, understanding how
Cube translates API queries into SQL queries, and providing transparency to SQL-savvy
end users.
Using this endpoint to take the SQL query and execute it against the data source directly
is not recommended as it bypasses Cube’s caching layer and other optimizations.
Request parameters:
If
disable_post_processing is set to true, Cube will try to generate the SQL
as if the query is run without post-processing, i.e., if it’s run as a
query with pushdown.
The response will contain a JSON object with the following properties under the sql key:
For queries with the
sql format, the response will also include the following additional
properties under the sql key:
For queries with the
sql format, in case of an error, the response will only contain
status, query_type, and error properties.
For example, an error will be returned if disable_post_processing was set to true but
the query can’t be run without post-processing.
Example
Request with a query in the REST (JSON) API format:{base_path}/v1/convert-query
Takes an API query in the specified input format and converts it to the specified
output format. Currently, only conversion from SQL API queries to
REST (JSON) API queries is supported.
This endpoint is useful for translating SQL API queries into equivalent REST (JSON) API
queries that can be used with the /v1/load endpoint.
Request parameters (JSON body):
The response will contain a JSON object with the following properties:
An error will be returned if the input query can’t be converted to the specified
output format, e.g., if the SQL API query requires post-processing on top of
REST (JSON) API capabilities or if the SQL API query results in multiple REST (JSON) API queries.
Example
Request to convert a SQL API query with a filter:{base_path}/v1/meta
In Cube Cloud, consider using the Metadata API instead.
It provides additional information such as data lineage.
public: false will not be returned.
Response
cubes- Array of cubes and viewsname- Codename of the cube/viewtype- Type can be “cube” or “view”title- Human-readable cube/view namemeta- Custom metadatameasures- Array of measures in this cube/viewdimensions- Array of dimensions in this cube/viewhierarchies- Array of hierarchies in this cubesegments- Array of segments in this cube/viewfoldersandnestedFolders- Arrays of flat and nested folder structures in this view, respectivelyconnectedComponent- An integer representing a join relationship. If the same value is returned for two cubes, then there is at least one join path between them.
{base_path}/v1/cubesql
Run the query to the SQL API and get the results.
This endpoint is part of the SQL API.
Headers
Response: a stream of newline-delimited JSON objects. The first object contains
the
schema property with column names and types, and optionally
lastRefreshTime indicating when the data was last refreshed.
The following objects contain chunks of the result set under the data property.
Each chunk includes one or more rows of the result set; the maximum number of rows
per chunk is set by
CUBESQL_CUBE_SCAN_MAX_BATCH_ROWS.
Example
Simple request:{base_path}/v1/running-query/{requestId}
Cancel a running query by its request ID. This endpoint cancels any in-flight
queries matching the given request ID across all query queues.
The request ID can be obtained from the x-request-id header sent with
the original query request to endpoints like
/v1/load or /v1/cubesql.
Response:
result— an array of cancelled query definitions. Empty array if no matching queries were found in the queue.
Example
Cancel a query:{base_path}/v1/pre-aggregations/jobs
Trigger pre-aggregation build jobs or retrieve statuses of such jobs.
This endpoint is part of the Orchestration API.
Triggering jobs
To trigger pre-aggregation builds, send a
POST request with a payload
including post as the action and selector properties. The response will
contain an array of tokens (identifiers) of triggered jobs.
Example request triggering builds of all pre-aggregations defined in all cubes
using an empty security context and a UTC timezone:
orders cube using an empty security context and a UTC timezone:
main pre-aggregation defined in the
orders cube using an empty security context and a UTC timezone:
main pre-aggregation defined in the
orders cube within date range with some security context data
and an America/Los_Angeles timezone:
Retrieving statuses of jobs
To retrieve statuses of previously triggered jobs, send a
POST request with a
payload including the tokens property.
In the status property of the payload, you can get the following statuses:
Example request:
Metadata API
Metadata API is only available in Cube Cloud.
{base_path}/v1/data-sources
Send a GET request to list configured data sources visible to the authenticated user.
Example request:
{base_path}/v1/entities
Send a GET request to list all cubes and views in the data model. Results are
sorted by type (cubes first), then by name. Each item contains only type and
name; use /v1/entities/{name} or
/v1/entities/all for detailed metadata.
Query parameters:
Example request:
data is an array of entities; pagination reports the
total number of entities before offset and limit are applied:
{base_path}/v1/entities/{name}
Send a GET request to get detailed metadata for a single cube or view.
Path parameters:
Response includes:
type- Eithercubeorviewname- The cube or view nametitle- Human-readable titledescription- Description from the data model, or an empty stringtable_references- Data lineage to source tables, each withdata_source,table, and, if the table is qualified,schemacube_references- Relationships to other cubes, each as an object withtype(currently alwaysupstream) andcubemeasuresanddimensions- Arrays of members, sorted by name
sql is the member’s SQL expression as written in the data model, with any
enclosing quotes removed — for example COUNT(*), ${CUBE}.status, or
${total_amount} - ${refunds}. References to other members appear as ${member}
interpolations, and ${CUBE} refers to the cube’s own table alias. Members of a
view carry the alias expression they resolve to, e.g. ${orders.total_amount}.
Example request:
{base_path}/v1/entities/all
Send a POST request to get detailed metadata for multiple cubes and views in one request.
Request body:
Query parameters:
If neither
cubes nor views is provided, all cubes and views are returned.
Example request:
data is an array of entities, each in the same format as the
single-entity response above; pagination reports the total number of matching
entities before offset and limit are applied: