Skip to main content

/o/analytics/countries

Endpoint

/o/analytics/countries

Overview

Returns top-country aggregates in fixed output blocks: 30days, 7days, and today.

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).
periodStringNoAccepted but ignored by this endpoint. Response always includes fixed blocks.
timezoneStringNoOptional timezone override.
timestampNumberNoOptional reference timestamp.

Configuration Impact

SettingDefaultAffectsUser-visible impact
api.total_userstrueUnique-user correctionWhen disabled, total-user correction path is skipped.
api.metric_changestrueCorrection historyWhen disabled, change-history adjustments are not applied.

Response

Success Response

{
"30days": [
{"country": "United States", "code": "us", "t": 121, "u": 14, "n": 11},
{"country": "Spain", "code": "es", "t": 87, "u": 10, "n": 6}
],
"7days": [
{"country": "United States", "code": "us", "t": 10, "u": 3, "n": 0}
],
"today": [
{"country": "United States", "code": "us", "t": 1, "u": 1, "n": 0}
]
}

Response Fields

FieldTypeDescription
30daysArrayCountry rows for last 30 days.
7daysArrayCountry rows for last 7 days.
todayArrayCountry rows for current day/hour window.
period[].countryStringCountry display name.
period[].codeStringLowercase ISO country code.
period[].tNumberTotal sessions for that country.
period[].uNumberTotal users for that country.
period[].nNumberNew users for that country.

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":"App does not exist"}

Behavior/Processing

Behavior Modes

  • Single mode:
    • Internally computes three periods (30days, 7days, hour) and returns them as 30days, 7days, today.

Impact on Other Data

  • Read-only endpoint. Does not update country aggregates.

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}Country/session aggregate sourceRead to build country ranking per fixed period block.
countly.app_users{appId}Total-user correction baselineRead when total-user correction is enabled.
countly.metric_changes{appId}Correction historyRead when metric-change correction is enabled.

Examples

Example 1: Read country metrics

/o/analytics/countries?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2

Operational Considerations

  • Output is fixed to three blocks regardless of supplied period.
  • Country list is limited to top countries by internal ranking.

Last Updated

2026-02-17