Examples
How to perform Metrics API queries on the order resource
Breakdown
The following request performs a breakdown query on the order resource:
curl -g -X POST \
'https://{{your_domain}}.commercelayer.io/metrics/orders/breakdown' \
-H 'Accept: application/vnd.api.v1+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {{your_access_token}}' \
-d '{
"breakdown": {
"by": "billing_address.city",
"field": "order.total_amount_with_taxes",
"operator": "stats",
"sort": "desc",
"limit": 10,
"breakdown": {
"by": "line_items.code",
"field": "line_items.total_amount",
"operator": "sum",
"sort": "asc",
"limit": 10
}
},
"filter": {
"order": {
"date_from": "2021-02-28T00:00:00Z",
"date_to": "2022-02-28T23:59:59Z",
"date_field": "current_date"
},
"market": {
"names": {
"in": ["USA"]
}
}
}
}'On success, the API responds with a 200 OK status code, returning the aggregated values in the data object and extra information in the meta object:
Date breakdown
The following request performs a date breakdown query on the order resource:
On success, the API responds with a 200 OK status code, returning the aggregated values over the selected time intervals in the data object and extra information in the meta object:
Stats
The following request performs a stats query on the order resource:
On success, the API responds with a 200 OK status code, returning the computed value in the data object and additional information in the meta object:
Search
The following request performs a search query on the order resource:
On success, the API responds with a 200 OK status code, returning the requested fields in the data object and additional information alongside pagination in the meta object:
Last updated

