Use this API to retrieve recent most common languages in a specified date range. It is a locale language code in BCP 47 format. We detect languages from visitor's http request header Accept-Language.
import { U301 } from 'u301';
const apiKey = '<YOUR_API_KEY>';
const workspaceId = '<YOUR_WORKSPACE_ID>';
const u301 = new U301({
apiKey,
workspaceId,
});
const clicks = await u301.analytics.getTopLanguages({
range: '1m',
timezone: 'Europe/London'
})Request
| Name | Location | Type | Required | Default | Description |
|---|---|---|---|---|---|
| Authorization | Header | string | Bearer token used for authentication. | ||
| workspaceId | Query | string | Workspace identifier for multi‑tenant routing. | ||
| range | Query | string | Date range for data aggregation. | ||
| timezone | Query | string | UTC | Timezone for data aggregation. See Timezone for details. |
Response
Data is an array of objects, each object contains the language label and click count. Language examples (BCP 47): en-US, en-GB, zh-CN, zh-TW, fr-FR, de-DE, es-ES.
| Name | Type | Description |
|---|---|---|
| datetimeRange | string[] | Date range for data aggregation. The format is an array of two strings, each string is a timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. |
| range | string | Date range for data aggregation. |
| data[].label | string | Label for data aggregation. |
| data[].click | number | Click count for data aggregation. |
{
"datetimeRange": [
"2025-11-01T00:00:00.000Z",
"2025-11-30T23:59:59.999Z"
],
"range": "1m",
"data": [
{
"label": "en-US",
"click": 88
},
{
"label": "en-GB",
"click": 23
},
{
"label": "zh-CN",
"click": 21
},
{
"label": "de-DE",
"click": 14
},
{
"label": "fr-FR",
"click": 12
},
{
"label": "es-ES",
"click": 7
},
{
"label": "zh-TW",
"click": 4
}
]
}Last updated on