Analytics API
Access revenue and sales analytics data.
Revenue Statistics
http
GET /api/external/v1/analytics/revenueQuery Parameters
| Parameter | Type | Description |
|---|---|---|
from | string | Start date (YYYY-MM-DD) |
to | string | End date (YYYY-MM-DD) |
granularity | string | day, week, month (default: day) |
Example Request
bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/analytics/revenue?from=2025-01-01&to=2025-01-31&granularity=day" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"Response
json
{
"success": true,
"data": {
"total_revenue": "2499.85",
"total_orders": 87,
"average_order_value": "28.73",
"currency": "USD",
"timeline": [
{
"date": "2025-01-01",
"revenue": "89.97",
"orders": 3
},
{
"date": "2025-01-02",
"revenue": "149.95",
"orders": 5
}
]
}
}Sales Statistics
http
GET /api/external/v1/analytics/salesQuery Parameters
| Parameter | Type | Description |
|---|---|---|
from | string | Start date (YYYY-MM-DD) |
to | string | End date (YYYY-MM-DD) |
limit | integer | Number of top products (default: 10) |
Example Request
bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/analytics/sales?from=2025-01-01&to=2025-01-31" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"Response
json
{
"success": true,
"data": {
"total_items_sold": 125,
"unique_customers": 72,
"top_products": [
{
"id": 1,
"name": "VIP Rank",
"quantity_sold": 45,
"revenue": "449.55"
},
{
"id": 2,
"name": "MVP Rank",
"quantity_sold": 28,
"revenue": "839.72"
}
],
"sales_by_category": [
{
"category": "Ranks",
"quantity": 73,
"revenue": "1289.27"
},
{
"category": "Items",
"quantity": 52,
"revenue": "519.48"
}
]
}
}Customer Analytics
http
GET /api/external/v1/analytics/customersQuery Parameters
| Parameter | Type | Description |
|---|---|---|
from | string | Start date (YYYY-MM-DD) |
to | string | End date (YYYY-MM-DD) |
Example Request
bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/analytics/customers?from=2025-01-01&to=2025-01-31" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"Response
json
{
"success": true,
"data": {
"new_customers": 45,
"returning_customers": 27,
"total_customers": 72,
"average_lifetime_value": "34.72",
"customer_retention_rate": "37.5"
}
}Response Fields
Revenue Object
| Field | Type | Description |
|---|---|---|
total_revenue | string | Total revenue in period |
total_orders | integer | Number of orders |
average_order_value | string | Average order amount |
currency | string | Currency code |
timeline | array | Revenue by date |
Sales Object
| Field | Type | Description |
|---|---|---|
total_items_sold | integer | Total items sold |
unique_customers | integer | Unique customers |
top_products | array | Best selling products |
sales_by_category | array | Sales grouped by category |
Errors
| Status | Error | Description |
|---|---|---|
| 401 | Unauthorized | Invalid or missing token |
| 403 | Forbidden | Token lacks analytics:read scope |
| 422 | Unprocessable | Invalid date range |
