Skip to main content

Compare - Events

Endpoint

/o/compare/events

Overview

Compares multiple events within one app and returns event time-series payloads keyed by event name.

Authentication

Countly API supports three authentication methods:

  1. API key query parameter: api_key=YOUR_API_KEY
  2. Auth token query parameter: auth_token=YOUR_AUTH_TOKEN
  3. Auth token header: countly-token: YOUR_AUTH_TOKEN

Permissions

Requires compare Read permission.

Request Parameters

ParameterTypeRequiredDescription
eventsJSON String (Array)YesJSON-stringified event key list. Max 20 events.
app_idStringYesApp ID used for event collection resolution and permission validation.
periodStringNoStandard Countly period parameter.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

events Array Structure

Example decoded value:

[
"Login",
"Purchase",
"[CLY]_group_Checkout"
]

Response

Success Response

{
"Login": {
"2026": {
"2": {
"17": {
"0": { "c": 5 },
"1": { "c": 3 },
"c": 52
}
}
},
"meta": {
"segments": ["Method"],
"Method": ["Password", "Face ID"]
}
},
"Purchase": {
"2026": {
"2": {
"17": {
"0": { "c": 2 },
"c": 14
}
}
},
"meta": {
"segments": []
}
}
}

Response Fields

FieldTypeDescription
(root object)ObjectRoot map keyed by requested event names.
event_keyObjectTime-series event payload for that event.
event_key.metaObjectSegment metadata for event payload.

Error Responses

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 400
{
"result": "Missing parameter: events"
}
  • 400
{
"result": "Maximum length for parameter events is 20"
}
  • 401
{
"result": "No app_id provided"
}
  • 401
{
"result": "User does not have right"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Standard eventsEvent key does not start with [CLY]_group_Hashes key with app ID and fetches per-event time object from events data collections.Raw object keyed by input event names
Event groupsEvent key starts with [CLY]_group_Fetches merged event group payload through grouped event fetch flow.Raw object keyed by input event names

Impact on Other Data

  • Read-only endpoint.

Operational Considerations

  • The endpoint performs one fetch path per requested event key, then combines results into a single object.
  • Grouped events ([CLY]_group_...) add merge work on top of event reads and can increase response time for large groups.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission checksReads member account, role, lock state, and feature access rights.
countly.appsApp validationValidates app_id and loads app context (for timezone/period handling).
countly.events_dataEvent series data sourceReads time-series event documents using app-and-event-hash _id prefixes.
countly.event_groupsGrouped-event mappingReads event group definitions and source-event membership for [CLY]_group_... keys.

Examples

Compare two standard events

/o/compare/events?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
period=7days&
events=["Login","Purchase"]

Compare grouped event and standard event

/o/compare/events?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
period=30days&
events=["[CLY]_group_Checkout","Purchase"]

Limitations

  • Maximum of 20 events per request.
  • Event names are used as response keys exactly as provided.

Last Updated

2026-02-17