Skip to main content
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.
Example request:
Example response:
Currently all fetched numericals are returned in the same format as driver returns it without any additional processing. Most of drivers return numerical values as strings instead of javascript integer or float to ensure there’s no loss of significance. Client code should take care of parsing such numerical values.

{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:
Response:
Request with a query in the SQL API format:
Response:
Request with a query in the SQL API format that is executed with post-processing:
Response:
Request with a query in the SQL API format that is forced to be executed without post-processing, i.e., as a query with pushdown:
Response:

{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:
Successful response:

{base_path}/v1/meta

In Cube Cloud, consider using the Metadata API instead. It provides additional information such as data lineage.
Get meta-information for cubes and views defined in the data model. Information about cubes and views with public: false will not be returned. Response
  • cubes - Array of cubes and views
    • name - Codename of the cube/view
    • type - Type can be “cube” or “view”
    • title - Human-readable cube/view name
    • meta - Custom metadata
    • measures - Array of measures in this cube/view
    • dimensions - Array of dimensions in this cube/view
    • hierarchies - Array of hierarchies in this cube
    • segments - Array of segments in this cube/view
    • folders and nestedFolders - Arrays of flat and nested folder structures in this view, respectively
    • connectedComponent - 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.
Example request:
Example response:

{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:
Response:
Simple request with a query that returns multiple columns:
Response:

{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:
Example response when a query was cancelled:
Example response when no matching query was found:

{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:
Example request triggering builds of all pre-aggregations defined in the orders cube using an empty security context and a UTC timezone:
Example request triggering builds of the main pre-aggregation defined in the orders cube using an empty security context and a UTC timezone:
Example request triggering builds of the main pre-aggregation defined in the orders cube within date range with some security context data and an America/Los_Angeles timezone:
Example response:

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:
Example response:

Metadata API

Metadata API is only available in Cube Cloud.
These endpoints provide programmatic access to data model metadata for data catalogs, lineage tools, and other integrations. To access these endpoints, you need a JWT token which can be obtained via the Control Plane API.

{base_path}/v1/data-sources

Send a GET request to list configured data sources visible to the authenticated user. Example request:
Example response:

{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:
Example response. 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 - Either cube or view
  • name - The cube or view name
  • title - Human-readable title
  • description - Description from the data model, or an empty string
  • table_references - Data lineage to source tables, each with data_source, table, and, if the table is qualified, schema
  • cube_references - Relationships to other cubes, each as an object with type (currently always upstream) and cube
  • measures and dimensions - Arrays of members, sorted by name
Each member includes: 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:
Example response:

{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:
Example response. 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:

Health checks

/readyz

Reports if the deployment has successfully started. To do so, it will try to test the connection to the default data source. Example of a successful request:
Example of a failed response:

/livez

Reports if the deployment is still healthy. This is confirmed by testing any existing connections to data sources. Example of a successful response:
Example of a failed response: