Analytics Guide
Access revenue reports and sales data to build custom dashboards and reporting.
Revenue Analytics
Get revenue data with configurable time periods and grouping.
bash
curl "https://yourstore.pixlpay.net/api/external/v1/analytics/revenue" \
-H "Authorization: Bearer YOUR_API_TOKEN"Query Parameters
| Parameter | Type | Description |
|---|---|---|
start_date | date | Start of date range (default: 30 days ago) |
end_date | date | End of date range (default: today) |
group_by | string | Grouping: day, week, month |
Example
bash
curl "https://yourstore.pixlpay.net/api/external/v1/analytics/revenue?start_date=2025-01-01&end_date=2025-01-31&group_by=day" \
-H "Authorization: Bearer YOUR_API_TOKEN"Response
json
{
"success": true,
"data": {
"summary": {
"total_revenue": "4523.45",
"total_orders": 152,
"average_order_value": "29.76",
"total_fees": "135.70"
},
"breakdown": [
{
"period": "2025-01-01",
"order_count": 5,
"total_revenue": "149.95",
"total_fees": "4.50",
"average_order_value": "29.99"
},
{
"period": "2025-01-02",
"order_count": 8,
"total_revenue": "239.92",
"total_fees": "7.20",
"average_order_value": "29.99"
}
]
}
}Sales Analytics
Get product performance and sales breakdown.
bash
curl "https://yourstore.pixlpay.net/api/external/v1/analytics/sales" \
-H "Authorization: Bearer YOUR_API_TOKEN"Query Parameters
| Parameter | Type | Description |
|---|---|---|
start_date | date | Start of date range |
end_date | date | End of date range |
Response
json
{
"success": true,
"data": {
"top_products": [
{
"id": 5,
"name": "VIP Rank",
"units_sold": 85,
"total_revenue": "2549.15"
},
{
"id": 12,
"name": "100 Coins",
"units_sold": 234,
"total_revenue": "1169.66"
},
{
"id": 8,
"name": "Premium Crate",
"units_sold": 67,
"total_revenue": "669.33"
}
],
"sales_by_type": [
{
"type": "digital",
"order_count": 142,
"units_sold": 386,
"total_revenue": "4388.12"
},
{
"type": "subscription",
"order_count": 10,
"units_sold": 10,
"total_revenue": "135.33"
}
]
}
}Common Use Cases
Custom Dashboard
Build a revenue overview dashboard:
javascript
async function getDashboardData() {
const [revenue, sales] = await Promise.all([
pixlpay.getRevenueAnalytics({
start_date: getThirtyDaysAgo(),
end_date: getToday(),
group_by: 'day'
}),
pixlpay.getSalesAnalytics({
start_date: getThirtyDaysAgo(),
end_date: getToday()
})
]);
return {
summary: revenue.summary,
revenueChart: revenue.breakdown.map(d => ({
date: d.period,
revenue: parseFloat(d.total_revenue),
orders: d.order_count
})),
topProducts: sales.top_products.slice(0, 5),
salesByType: sales.sales_by_type
};
}Monthly Report
Generate a monthly revenue report:
javascript
async function getMonthlyReport(year, month) {
const startDate = `${year}-${String(month).padStart(2, '0')}-01`;
const endDate = getLastDayOfMonth(year, month);
const [currentMonth, previousMonth] = await Promise.all([
pixlpay.getRevenueAnalytics({
start_date: startDate,
end_date: endDate,
group_by: 'day'
}),
pixlpay.getRevenueAnalytics({
start_date: getPreviousMonthStart(year, month),
end_date: getPreviousMonthEnd(year, month),
group_by: 'day'
})
]);
const currentRevenue = parseFloat(currentMonth.summary.total_revenue);
const previousRevenue = parseFloat(previousMonth.summary.total_revenue);
const growth = ((currentRevenue - previousRevenue) / previousRevenue) * 100;
return {
month: `${year}-${month}`,
revenue: currentRevenue,
orders: currentMonth.summary.total_orders,
averageOrderValue: currentMonth.summary.average_order_value,
growthPercent: growth.toFixed(1),
dailyBreakdown: currentMonth.breakdown
};
}Product Performance Tracking
Track how products perform over time:
javascript
async function getProductPerformance(productId, periods = 12) {
const data = [];
for (let i = 0; i < periods; i++) {
const { startDate, endDate } = getMonthRange(i);
const sales = await pixlpay.getSalesAnalytics({
start_date: startDate,
end_date: endDate
});
const product = sales.top_products.find(p => p.id === productId);
data.push({
period: startDate.slice(0, 7),
units: product?.units_sold || 0,
revenue: parseFloat(product?.total_revenue || 0)
});
}
return data.reverse();
}Export to BI Tools
Export data in a format suitable for BI tools:
javascript
async function exportForBI(startDate, endDate) {
const [revenue, sales, orders] = await Promise.all([
pixlpay.getRevenueAnalytics({ start_date: startDate, end_date: endDate, group_by: 'day' }),
pixlpay.getSalesAnalytics({ start_date: startDate, end_date: endDate }),
pixlpay.getOrders({ start_date: startDate, end_date: endDate, per_page: 100 })
]);
return {
metrics: {
total_revenue: revenue.summary.total_revenue,
total_orders: revenue.summary.total_orders,
average_order_value: revenue.summary.average_order_value,
top_product: sales.top_products[0]?.name
},
daily_revenue: revenue.breakdown,
product_performance: sales.top_products,
orders: orders.data
};
}Required Scopes
| Endpoint | Required Scope |
|---|---|
| GET /analytics/revenue | analytics:read |
| GET /analytics/sales | analytics:read |