Breakdown
How to perform a breakdown query and how it works
Breakdowns are aggregations that summarize your data as metrics (based on specific operators) or statistics, computed on field values. When performing a breakdown query on the Metrics API endpoint you get in the response the value of the computation (based on the selected operator
) on the selected field
, aggregated by
another field.
Request
To perform a breakdown query send a POST
request to the /{{resource_name}}/breakdown
endpoint specifying the query keys and filter parameters:
Query keys
by
String
The field you want the results of the query aggragated by.
field
String
The field you want the metrics or statistics computed on.
operator
String
The computing operator.
condition
Object
One of:
"eq": ...
"ne": ...
"gt": ...
"gte": ...
"lt": ...
"lte": ...
"gt_lt": [...]
"gte_lte": [...]
"gte_lt": [...]
"gt_lte": [...]
(default is no condition).
sort
String
The way you want the results of the query to be sorted.
One of asc
or desc
(default is desc
).
limit
Integer
The maximum number of records shown in the response.
Default is 10
, max is 100
.
breakdown
Object
Nesting breakdowns
You cannot group the nested breakdown by the same field by which you're already grouping the parent breakdown.
Response
The response of a breakdown query returns an aggregation by the field specified in the by
key, containing the value of the computation (based on the operator specified in the operator
key) on the field specified in the field
key. If the query contains a nested breakdown, it is also detailed for each item of the array:
label
The different values of the by
field the results are aggregated by.
value
The result of the computation for the specific label
.
Examples
Single breakdown
The following request performs a breakdown query to get the total count of orders by market, as long as the computed result is within a specific range:
Nested breakdown
The following request performs a breakdown query to get the total count of orders by market, as long as the computed result is within a specific range. For each market, a breakdown of the orders' total amounts by currency code is also requested:
Last updated