# Aggregations

This endpoint retrieves aggregated data related to a specific module identified by {module}. It allows querying and aggregation of data based on various parameters such as grouping, aggregation functions, sorting, filtering, and dimensions.

# Endpoint

GET /api/modules/{module}/aggregations

This endpoint accepts a {module} path parameter (e.g., user, products) to specify the data source.

# Request Parameters

All parameters are query parameters:

Parameter Type Description & Example
group-by array of strings
(comma-separated)
Specifies the fields to group the data by.
/api/modules/orders/aggregations?group-by=customer_id,region
aggregates array of strings
(comma-separated)
Defines the aggregation functions to apply.
/api/modules/products/aggregations?aggregates=count(id),sum(price),avg(rating)
limit integer The maximum number of aggregated results to return.
  • Default: 1000
  • Minimum: 1
sort array of strings
(comma-separated)
Controls the sort order of the aggregated results.
  • Fields can be prefixed with + for ascending or - for descending (e.g., +name, -total_sales)
  • Alternatively, you can use the :asc or :desc postfix (e.g., name:desc, created_time:asc)
  • /api/modules/user/aggregations?sort=-registration_date,+username
query string An alias for the query parameter.
dimensions string Used for specific dimensional filtering.
/api/modules/sales/aggregations?dimensions=channel%20%3D%20%27online%27%20AND%20locale%20%3D%20%27en_US%27

# Response Structure (HTTP 200 OK)

The response will be a JSON object containing a result array. Each object within the result array represents a row of aggregated data, with keys corresponding to your group-by fields and the names of your aggregates.

{
  "result": [
    {
      "group_field_1": "value1",
      "group_field_2": "valueA",
      "count(id)": 150,
      "sum(price)": 15000.75
    },
    {
      "group_field_1": "value2",
      "group_field_2": "valueB",
      "count(id)": 90,
      "sum(price)": 8000.20
    }
  ]
}

Supported Fields

Only native and not list fields are fully supported in the group-by, aggregates, and sort parameters. Support for other fields and relationships is experimental and not guaranteed.

Request missing documentation