Skip to main content

/o/analytics/tops

Endpoint

/o/analytics/tops

Overview

Returns top lists for built-in categories or requested metric keys.

Authentication

  • API Key (parameter): api_key=YOUR_API_KEY
  • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
  • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

Permissions

  • Requires read access to feature core for the target app.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or use auth_token)Dashboard API authentication key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
app_idStringYesApp ID (24-char hex).
periodStringNoRequested period.
metricStringNoSingle metric key mode.
metricsJSON String (Array) or ArrayNoMulti-metric mode.
timezoneStringNoOptional timezone override.
timestampNumberNoOptional reference timestamp.

Parameter Semantics

  • If metric is set, endpoint returns one array result.
  • If metrics is set, endpoint returns an object keyed by each metric.
  • If metrics parsing fails, endpoint returns {}.
  • If neither metric nor metrics is set, endpoint returns built-in top lists.

Configuration Impact

SettingDefaultAffectsUser-visible impact
api.total_userstrueMetric/metrics mode unique-user correctionWhen disabled, total-user correction is skipped in metric-based branches.
api.metric_changestrueMetric/metrics correction historyWhen disabled, metric-change correction is not applied.

Response

Success Response

Default mode (no metric / metrics):

{
"platforms": [{"name": "iOS", "value": 236, "percent": 47.5}],
"resolutions": [{"name": "600x1024", "value": 50, "percent": 10.4}],
"carriers": [{"name": "Metro Pcs", "value": 58, "percent": 11.8}],
"countries": [{"name": "United States", "value": 121, "percent": 24.5}]
}

Single metric mode (metric=countries):

[
{"name": "United States", "value": 121, "percent": 24.5},
{"name": "Spain", "value": 87, "percent": 17.6}
]

Multi-metric mode (metrics=["countries","platforms"]):

{
"countries": [{"name": "United States", "value": 121, "percent": 24.5}],
"platforms": [{"name": "iOS", "value": 236, "percent": 47.5}]
}

Response Fields

FieldTypeDescription
platformsArrayDefault mode top platforms.
resolutionsArrayDefault mode top resolutions.
carriersArrayDefault mode top carriers.
countriesArrayDefault mode top countries or metric result key.
metric_nameArrayMetric-mode list for requested metric(s).
list[].nameStringSegment display name.
list[].valueNumberSegment aggregate value.
list[].percentNumberSegment percentage share.

Error Responses

Status Code: 400 Bad Request

{"result":"Missing parameter \"api_key\" or \"auth_token\""}

Status Code: 400 Bad Request

{"result":"Missing parameter \"app_id\""}

Status Code: 401 Unauthorized

{"result":"User does not have right"}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Default tops modemetric and metrics are both omittedReads users/device_details/carriers aggregates and returns built-in top lists.Raw root object with keys like platforms, resolutions, carriers, countries.
Single metric modemetric is providedResolves metric-to-collection mapping and returns one top list for that metric.Raw root array.
Multi-metric modemetrics is provided as array/JSON string arrayResolves each metric and returns one list per metric key.Raw root object keyed by metric names.

Impact on Other Data

  • Read-only endpoint.

Audit & System Logs

  • No /systemlogs action is emitted by this endpoint.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission validationReads member record by api_key or auth_token to verify read access.
countly.appsApp context validationReads app record (timezone, app state) for the requested app_id.
countly.users{appId}Countries/users aggregate sourceRead for default and metric branches.
countly.device_details{appId}Platform/resolution aggregate sourceRead for default and metric branches.
countly.carriers{appId}Carrier aggregate sourceRead for default and metric branches.
countly.app_users{appId}Total-user correction baselineRead in metric/metrics branches when correction is enabled.
countly.metric_changes{appId}Correction historyRead in metric/metrics branches when correction history is enabled.

Examples

Example 1: Built-in top lists

/o/analytics/tops?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
period=30days

Example 2: One metric

/o/analytics/tops?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
metric=countries&
period=30days

Example 3: Multiple metrics

/o/analytics/tops?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
metrics=["countries","platforms"]&
period=30days

Operational Considerations

  • Metric branches may query additional collections and correction sources.
  • High-cardinality metrics can increase response size.

Limitations

  • Invalid metrics JSON returns {}.
  • Unsupported metric keys return empty arrays in metric-mode results.

Last Updated

2026-02-17