purchaseAnalytics
Requires permission analytics:organization:read.
Purchase analytics for a period: total purchases and orders, average order value, growth, orders by status, purchases by period and category, and top suppliers and products. Needs the purchase orders feature on your plan. Org-wide purchase spend: needs the organization analytics read permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
query PurchaseAnalytics($period: AnalyticsPeriod!) {
purchaseAnalytics(period: $period) {
averageOrderValue
ordersGrowth
purchasesGrowth
totalOrders
totalPurchases
ordersByStatus {
status
count
value
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query PurchaseAnalytics($period: AnalyticsPeriod!) {\n purchaseAnalytics(period: $period) {\n averageOrderValue\n ordersGrowth\n purchasesGrowth\n totalOrders\n totalPurchases\n ordersByStatus {\n status\n count\n value\n }\n }\n}",
"variables": {
"period": "LAST_6_MONTHS"
}
}
EOF
Variables:
{
"period": "LAST_6_MONTHS"
}
Response:
{
"data": {
"purchaseAnalytics": {
"averageOrderValue": 0,
"ordersGrowth": 0,
"purchasesGrowth": 0,
"totalOrders": 0,
"totalPurchases": 0,
"ordersByStatus": [
{
"status": "string",
"count": 0,
"value": 0
}
]
}
}
}
purchaseAnalytics(
period: AnalyticsPeriod!
): PurchaseAnalytics!
Arguments
purchaseAnalytics.period ● AnalyticsPeriod! non-null enum
The period to report on.
Type
PurchaseAnalytics object
Purchasing figures for the period.