One-time Queries
Learn how to use our three one-time query endpoints to submit a new query, check the query run status, and fetch the completed query results.
One-time queries are good for pulling data over custom date ranges. One-time queries must be submitted anew for every unique run if your team wants to run the same report (using the same metrics, dimensions, and/or filters) over unique date ranges (using unique start and end date parameters).
Getting data back from a one-time query is a three-step process using each of the below one-time API endpoints:
Run a
/submit/
call to submit your new query and receive a query ID.Run a
/status/
call to check the status of your submitted query using the query ID from your previous call to the/submit/
endpoint. Continue running as frequently as every ten seconds or so until you receive acompleted
status for your query.Once the status of your query is
completed
, run a/fetch/
call with the original query ID to download your completed query results.
Submit One-time Query
GET
https://api.chartbeat.com/query/v2/submit/
Submitting a query to the /submit/
endpoint will initiate your query run. More complex queries may take several minutes to complete. The expected return value of this call is a query_id
that can be used to both check the status of your query as well as to access the returned data.
The "filter" parameter is a stand-in for the dimension-parameter you want to filter by. To include a filter in your submitted query, use dimension
as the query param key, and set it to a value (or multiple values) to filter by for that query.
Note: Metrics and dimensions should be declared before including filters. They accept a comma separated list of values.
Path Parameters
Name | Type | Description |
---|---|---|
endpoint | string | Append |
Query Parameters
Name | Type | Description |
---|---|---|
apikey (see note) | string | NOTE: Your API key should no longer be set as a query param; instead, pass it in the HTTP header |
sort_column | string | Must match a value in your metrics or dimensions parameter |
sort_order | string | Either |
start | string | YYYY-MM-DD |
end | string | YYYY-MM-DD |
endpoint | string | Either |
host | string | The site on which you are querying |
limit | integer | Base-10 values only |
tz | string | The timezone you'd like to run the query in a valid Olson timezone format, e.g. America/New_York. |
metrics | string | Comma-separated values |
dimensions | string | Comma-separated values |
{filter}= | string |
|
Get Status of One-time Query
GET
https://api.chartbeat.com/query/v2/status/
Use the /status/
endpoint to check on the status of your query. If you are programmatically querying Chartbeat data, you should wait until your status
value returns "completed" before making the fetch call (see below), or you will get an error.
Possible status responses include submitted, running, completed, downloaded, and deleted.
Query Parameters
Name | Type | Description |
---|---|---|
query_id | string | Value returned from call to |
host | string | The site you are querying |
apikey (see note) | string | NOTE: Your API key should no longer be set as a query param; instead, pass it in the HTTP header |
Fetch One-time Query
GET
https://api.chartbeat.com/query/v2/fetch/
The /fetch/
endpoint will return the data for a completed query (default is in .csv format).
Query Parameters
Name | Type | Description |
---|---|---|
| string | Value returned from call to |
| string | The site you are querying |
| string | Set to |
apikey (see note) | string | NOTE: Your API key should no longer be set as a query param; instead, pass it in the HTTP header |
Last updated