Skip to main content
Version: 26.01

Analytics - Run Aggregate Query

Endpoint​

/o/aggregate

Overview​

Runs a stored-data query as a long-running task. The response contains the result when the query finishes in time, or a task to check later when it does not.

Authentication​

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

Permissions​

Requires a valid dashboard user. When query.appID is set, the user must be a global admin or have access to every listed app.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.
queryJSON String (Object)YesQuery definition.
query.appIDString or ArrayNoApp ID or list of app IDs to query. Defaults to the app_id parameter.
app_idStringConditionalUsed as query.appID when the query does not set it.
periodStringNoUsed as query.period when the query does not set it.
periodOffsetNumberNoUsed as query.periodOffset when the query does not set it.
no_cacheBooleanNoIf set, a cached result is not used.

Examples​

Run a query​

/o/aggregate?api_key=YOUR_API_KEY&app_id=6991c75b024cb89cdc04efd2&period=30days&query={"appID":"6991c75b024cb89cdc04efd2"}

Response​

Success Response​

{
"result": {}
}

Response Fields​

FieldTypeDescription
resultObjectQuery result, or task information when the query is still running.

Error Responses​

  • 400
{
"result": "Missing parameter \"query\""
}
  • 400
{
"result": "Invalid query parameter"
}
  • 401
{
"result": "User does not have access right for this app"
}

Behavior​

  • Runs the query as a long task: if it takes longer than the server's request threshold, the response describes the running task instead of the data.
  • Query errors are returned with status 400.