Skip to main content

Locale - Languages Read

Endpoint

/o?method=langs

Overview

Returns language usage metrics for an app and selected period. Data is aggregated from locale metric documents and returned in Countly's standard time-object format.

Authentication

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions

Requires locale Read permission.

Request Parameters

ParameterTypeRequiredDescription
methodStringYesMust be langs.
api_keyStringYes (or use auth_token)API key for authentication.
auth_tokenStringNoAuth token as query parameter or countly-token header.
app_idStringConditionally requiredRequired for non-global users under read-permission validation.
periodStringNoTime range accepted by Countly period parser (default behavior follows shared fetch logic).
timezoneStringNoTimezone used for period calculations.
actionStringNoOptional mode switch. Use refresh to return only the latest refresh-focused slice instead of a full-period merge.

Examples

Read language metrics for current month

/o?method=langs&api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&period=month

Read language metrics for last 7 days

/o?method=langs&api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&period=7days

Response

Success Response

{
"2026": {
"2": {
"17": {
"langs": {
"en": {
"t": 24,
"u": 18,
"n": 6
},
"fr": {
"t": 8,
"u": 7,
"n": 2
}
}
}
}
},
"meta": {
"langs": [
"en",
"fr"
]
}
}

Response Fields

FieldTypeDescription
(root)ObjectRaw merged time object for locale metrics.
{year}ObjectYear bucket.
{year}.{month}ObjectMonth bucket.
{year}.{month}.{day}ObjectDay bucket containing language metric entries.
...langs.{lang_code}.tNumberTotal sessions for language code in period slice.
...langs.{lang_code}.uNumberUnique users for language code in period slice.
...langs.{lang_code}.nNumberNew users for language code in period slice.
meta.langsArrayLanguage codes present in the dataset.

Error Responses

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 400
{
"result": "Token not valid"
}
  • 401
{
"result": "No app_id provided"
}
  • 401
{
"result": "User does not exist"
}
  • 401
{
"result": "App does not exist"
}
  • 401
{
"result": "User does not have right"
}
  • 401
{
"result": "User is locked"
}
  • 401
{
"result": "Token is invalid"
}

Behavior

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Standard readaction is not refreshValidates access and returns merged locale time-object data for the requested period.Raw root object keyed by time buckets plus meta.
Refresh readaction=refreshValidates access and returns refresh-focused fields (latest daily/weekly/monthly slices and metadata).Raw root object with a reduced metric slice for fast refresh use.

Limitations

  • Metric granularity and shape follow shared Countly time-object fetch behavior.
  • Empty dataset returns an empty object.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission checksReads member account, role, lock state, and feature access rights.
countly.appsApp validation and context loadingValidates app_id and loads app timezone/country context for period handling.
countly.langsStores aggregated locale/language metricsReads language metric documents for the requested app and period.