Authentication
To make API calls to the Analytics API you should follow this guide to generate an API token.
Use the API token from in the Authorization header to call the endpoints below and fetch the required data
Querying the data
The analytics API uses the Cube semantic layer API. You can refer to their documentation for a full API reference.
Endpoints
Schema Endpoint
https://app.coho.ai/api/analytics/v1/meta
To get the latest schema available, you can send the following request:
curl -X GET https://app.coho.ai/api/analytics/v1/meta \
-H 'Content-Type: application/json' \
-H 'Authorization: <JWT Token>'
Query endpoint
https://app.coho.ai/api/analytics/v1/load
Here are a couple of examples to get you started:
User Count
To retrieve the user count grouped by account ID, you can use the following request:
GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"]}&queryType=multi
Daily Active Users (DAU)
To fetch Daily Active Users (DAU) data, you can apply a filter to retrieve data after yesterday's date:
GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"filters": [{"member": "users.last_event_time","operator": "afterDate","values": ["2024-09-12"]}]}&queryType=multi
Weekly Active Users (WAU)
To retrieve Weekly Active Users (WAU) data, use a filter to fetch data after last week's date:
GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"filters": [{"member": "users.last_event_time","operator": "afterDate","values": ["<last_week_date>"]}]}&queryType=multi
Monthly Active Users (MAU)
For Monthly Active Users (MAU) data, apply a filter to fetch data after last month's date:
GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"filters": [{"member": "users.last_event_time","operator": "afterDate","values": ["<last_month_date>"]}]}&queryType=multi
Date Range Filtering
You can also filter the data based on a specific date range by using the inDateRange
operator:
GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"filters": [{"member": "users.last_event_time","operator": "inDateRange","values": ["<start_date>","<end_date>"]}]}