Skip to main content
Analytics API

How to query your customer data using the Analytics API

Updated over a month ago

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

GET https://app.coho.ai/api/analytics/v1/load

Query Parameters:

Key

Value

query

A json query. See examples below.

queryType

multi

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 query:

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 only from yesterday:

GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"timeDimensions": [{"dimension": "users.last_event_time","dateRange": "yesterday"}]}&queryType=multi

Weekly Active Users (WAU)

To retrieve Weekly Active Users (WAU) data, use a filter to fetch data only from last week:

GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"timeDimensions": [{"dimension": "users.last_event_time","dateRange": "last week"}]}&queryType=multi

Monthly Active Users (MAU)

For Monthly Active Users (MAU) data, apply a filter to fetch data only from last month:

GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"timeDimensions": [{"dimension": "users.last_event_time","dateRange": "last month"}]}&queryType=multi

Quarterly Active Users (QAU)

For Quarterly Active Users (QAU) data, apply a filter to fetch data only from last quarter:

GET https://app.coho.ai/api/analytics/v1/load?query={"dimensions": ["users.account_id"],"measures": ["users.users_count"],"timeDimensions": [{"dimension": "users.last_event_time","dateRange": "last quarter"}]}&queryType=multi

Date Range Filtering

You can filter the data using relative or absolute date ranges in the dateRange property. For example:

  • "dateRange": "today"

  • "dateRange": "yesterday"

  • "dateRange": "this month"

  • "dateRange": "last month"

  • "dateRange": ["2023-01-01", "2023-01-31"]

Did this answer your question?