Skip to main content

Views - Query

Endpoint

/o?method=views

Overview

Queries view analytics data in multiple modes, including table output, totals, export query generation, view-name listings, and selected-view graph data.

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 views Read permission.

Request Parameters

ParameterTypeRequiredDescription
methodStringYesMust be views.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.
app_idStringConditionalRequired for non-global-admin users during read validation.
actionStringNoQuery mode selector (see semantics table).
periodStringNoStandard Countly period value.
segmentStringNoSegment key used for segmented view data.
segmentValStringNoSegment value for segment.
periodOffsetNumberNoClient offset (minutes) used in period shift for selected actions.
iDisplayStartNumberNoPagination start index (getTable, getTableNames).
iDisplayLengthNumberNoPagination length (getTable, getTableNames).
iSortCol_0NumberNoSort column index for table actions.
sSortDir_0StringNoSort direction (asc or desc).
sSearchStringNoSearch filter (getTable, getTableNames).
selectedViewsJSON String (Array)ConditionalRequired for default graph mode when action is not set. Example: [{"view":"6991c75..._home","name":"Home"}]
bucketStringNoGraph bucket for default graph mode (for example h, d, w, m).

Parameter Semantics

FieldExpected valuesBehavior
actiongetTable, getExportQuery, getTableNames, get_view_count, getTotals, listNames, emptySwitches response shape and processing branch.
selectedViewsJSON array of objects containing view IDsUsed only by default graph mode. If missing/empty, graph mode returns empty data.
periodOffsetInteger minutesAdjusts effective period window used by some aggregations.

Configuration Impact

SettingDefaultAffectsUser-visible impact
api.request_thresholdServer configurationProcessing flowgetTotals and default graph mode use long-task thresholding; response may include running: true while unique-count enrichment is still processing.

Response

Success Response

action=getTable:

{
"sEcho": "1",
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
"aaData": [
{
"_id": "6991c75b024cb89cdc04efd2_home",
"view": "/home",
"display": "Home",
"url": "https://your-server.com/home",
"t": 120,
"u": 95,
"d": 38,
"s": 44,
"e": 20,
"b": 15,
"br": 13,
"scr": 67
}
]
}

action=getTotals:

{
"_id": null,
"t": 1540,
"s": 730,
"b": 188,
"u": 521,
"lu": "2026-02-17T11:13:03.000Z",
"lu_diff": 42,
"running": false
}

action=getExportQuery:

{
"db": "countly",
"collection": "app_viewdata0f4f4d...",
"pipeline": [
{
"$match": {
"_id": {
"$regex": "^6991c75b024cb89cdc04efd2_"
}
}
}
],
"projection": {
"_id": true,
"view": true,
"url": true,
"display": true,
"u": true,
"t": true
}
}

Default graph mode (action empty):

{
"appID": "6991c75b024cb89cdc04efd2",
"data": {
"6991c75b024cb89cdc04efd2_home": {
"no-segment": {
"2026": {
"2": {
"17": {
"t": 23,
"u": 18
}
}
}
}
}
}
}

action=get_view_count:

{
"result": 128
}

Response Fields

FieldTypeDescription
sEchoStringEcho value for table-compatible responses.
iTotalRecordsNumberTotal records for table actions.
iTotalDisplayRecordsNumberFiltered total for table actions.
aaDataArrayTable rows for getTable/getTableNames.
dbStringExport source DB for getExportQuery.
collectionStringExport source collection for getExportQuery.
pipelineArrayAggregation pipeline for getExportQuery.
projectionObjectProjection map for getExportQuery.
resultNumberView count for get_view_count (returned as wrapped result).
appIDStringApp ID in default graph mode.
dataObject or ArrayGraph payload (default mode) or selected-action data payloads.
t, s, b, uNumberTotals response metrics (getTotals).
luStringLatest update timestamp (getTotals).
lu_diffNumberSeconds since latest update (getTotals).
runningBooleanIndicates totals enrichment is still running (getTotals).

Error Responses

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 401
{
"result": "No app_id provided"
}
  • 401
{
"result": "User does not have right"
}
  • 400
{
"result": "Missing request parameter: app_id"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Table modeaction=getTableAggregates view metrics, joins app_viewsmeta, applies search/sort/pagination.Raw object with aaData and table totals.
Export modeaction=getExportQueryBuilds export pipeline/projection and target collection metadata.Raw object with db, collection, pipeline, projection.
Table names modeaction=getTableNamesReads names/display values from app_viewsmeta with sort/pagination.Raw object with aaData and table totals.
Count modeaction=get_view_countCounts view-meta documents for app.Wrapped object: { "result": 42 } (number).
Totals modeaction=getTotalsAggregates totals and unique counts via long-task-enabled query runner flow.Raw totals object (may include running).
Names list modeaction=listNamesReturns all view names/display values when total count is below limit.Raw array.
Graph modeaction missing/emptyBuilds selected-view time models and applies unique-count enrichment.Raw object { appID, data }.

Impact on Other Data

  • Read-only endpoint. It does not create, update, or delete records.

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission checksReads member account, lock state, and feature access.
countly.appsApp validation/context loadingValidates app context for read access and period handling.
countly.app_viewdata and countly.app_viewdata{sha1(segment+appId)}View metric source dataReads segmented and non-segmented view metric documents.
countly.app_viewsmetaView metadata lookupReads view names, URLs, and custom display names.
countly_drill.drill_eventsUnique-count/graph enrichment inputReads [CLY]_view drill events for totals/graph unique calculations.

Examples

Table mode

/o?
method=views&
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
action=getTable&
period=30days&
iDisplayStart=0&
iDisplayLength=10

Totals mode

/o?
method=views&
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
action=getTotals&
period=7days

Graph mode for selected views

/o?
method=views&
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
period=30days&
selectedViews=[{"view":"6991c75b024cb89cdc04efd2_home","name":"/home"}]

Operational Considerations

  • getTotals and graph mode may perform heavy unique-count enrichment and can report running: true.
  • For large datasets, use pagination and targeted periods to reduce response size.

Limitations

  • listNames returns empty array when total view count is 10000 or higher.
  • Graph mode requires selectedViews for non-empty data output.

Last Updated

2026-02-17