Query API
Journey Analytics provides a query API that can be used to query your project at any time. This enable you to create your own dashboards or easily integrate data from Journey Analytics with other tools.
Queries can be sent using GET or POST methods.
End Point
https://app.cooladata.com/api/v2/projects/[project_id]/cql
Replace the [project_id] placeholder with your actual Project ID.
Header
Authorization:Token [User_API_Token]
ContentType:application/x-www-form-urlencoded //optional
Replace the [User_API_Token] placeholder with your actual user API Token found in the user profile side-bar.
ContentType: application/x-www-form-urlencoded: Only relevant for method:post. This parameter can also be omitted if the content is already URL encoded. Other content types are not supported.
Optional Headers:
TIMESTAMP
The default format for time-stamp properties returned in the query API is: yyyy-mm-dd hh:mm:ss. Add this header (without content) to the query to get time-stamp properties in the format in which they were sent. For example, event_time_ts will be returned in Epoch time in milliseconds.
Data/Payload
tq=[query]
&noCache=true //optional
&tqx=out:csv //optional
Replace the [query] placeholder with your actual query. The query should be written in CoolaSQL (CQL).
Optional Parameters:
noCache=true
Add to the query to force the system to ignore cache. All query results are cached for 30 minutes to provide fast response time. After 30 minutes it will be refreshed, regardless of how many queries were made during this time. Using noCache will only make a difference if the same query was first performed in the last 30 minutes, and data has been altered since. This isn't mandatory in the API.
tqx=out:csv
The default output of the query API is JSON. Add this to the query to get an output in the form of CSV instead.
Sample Invocations
The following queries includes both optional parameters for reference purpose – neither is mandatory.
Method: GET
The query should be URL encoded.
curl -H "Authorization:Token n8rwaqp6zj62yya3yj3pvysy7h9gvzn8" https://app.cooladata.com/api/v2/projects/123456/cql/?tq=select%20event_name,%20event_time_ts%20from%20cooladata%20where%20date_range(last%207%20days)%20limit%2010&noCache=true&tqx=out:csv
Method: POST
curl
-X POST
-H "Authorization:Token n8rwaqp6zj62yya3yj3pvysy7h9gvzn8"
-H "ContentType: application/urlencode"
-H "TIMESTAMP"
-d "noCache=true" \\optional
-d "tqx=out:csv" \\optional
-d "TQ=select event_name, event_time_ts from cooladata where date_range(last 7 days) limit 10"
https://app.cooladata.com/api/v2/projects/123456/cql/
Response
The default output of the query API is JSON, in the following format:
{version,status,Number of rows,Processed bytes,Total query time,sig,table{cols,rows}}
Note: The query API result set is limited to 5M rows.
Sample Response:
{
"version": "0.6",
"status": "ok",
"Number of rows": "15",
"Processed bytes": "2952",
"Total query time": "2129",
"sig": "1880384400",
"table": {
"cols": [
{
"id": "0",
"label": "date",
"type": "string",
"pattern": ""
}
],
"rows": [
{
"c": [{"v": "2013-05-01"}]
}
,...
]
}
}