Breakdown
How to perform a breakdown query and how it works
Last updated
How to perform a breakdown query and how it works
Last updated
Breakdowns are aggregations that summarize your data as metrics (based on specific ) or statistics, computed on field values. When performing a breakdown query on the Metrics API endpoint you get in the the value of the computation (based on the selected operator
) on the selected field
, aggregated by
another field.
To perform a breakdown query send a POST
request to the /{{resource_name}}/breakdown
endpoint specifying the and parameters:
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
You cannot group the nested breakdown by the same field by which you're already grouping the parent breakdown.
label
The different values of the by
field the results are aggregated by.
value
The result of the computation for the specific label
.
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:
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:
The available values for this key depend on the resource you're doing statistics on (see , , or for the related lists).
The available values for this key depend on the resource you're doing statistics on (see , , or for the related lists).
The available operators depend on the field
key value (see , , or for the related lists).
An additional constraint to fine-tune the set of records shown in the response, applied to the computed results of the query. It is available for that return single numeric (float or integer) values.
The optional .
The nested breakdown by
key available values depend of the parent breakdown by
key value (see , , or for the related lists).
Breakdowns can be nested recursively one into the other, up to one level (see ). The valid values allowed for the by
key of the nested breakdown are strictly dependent on the value you specified in the by
key of the parent breakdown. Hence, they are different for each resource you're doing statistics on (see , , and for the related lists).
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 , it is also detailed for each item of the array:
The following examples will be focused on the part of the request. So no specific or options will be defined (i.e. all the results will be filtered by the and the response won't include the request payload). See the section for more complex combinations of queries and filters.