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 a completed
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/
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 they 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.page/
or video/
to the endpoint URL above after /submit/
, before appending query parameters below. This determines whether your API call will query page or video data. The endpoint query parameter below is also required.asc
or desc
page
or video
filter_value
{query_id: "4ed64430-9049-469b-8eee-e38d265017dc"}
/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./submit/
endpoint{status: "", //submitted, running, completed, downloaded, or deletedmetrics: [//list of metrics being returned in the query],host: "YOURSITE.com",query_id: "4ed64430-9049-469b-8eee-e38d265017dc", //<-example query IDdimensions: [//list of dimensions being returned in the query],query_num: null}
/fetch/
endpoint will return the data for a completed query (default is in .csv format)./submit/
endpointjson
to return data formatted in JSON instead of CSV//Will return .csv formatted data, unless providing format=json parameter