Analytics
Base URL : /api/v1/admin/org/analytics
Analytics avancées avec comparaison de périodes. Pour les statistiques simples, voir Statistiques.
Permissions (toutes) : analytics.read
Paramètres communs
from et to sont requis (format YYYY-MM-DDTHH:MM:SS). compare_from et compare_to sont optionnels : la comparaison n'est calculée que si les deux sont fournis.
| Param | Requis | Description |
|---|---|---|
from | Oui | Début de période (inclus) |
to | Oui | Fin de période (exclu) |
compare_from | Non | Début de la période de comparaison |
compare_to | Non | Fin de la période de comparaison |
Enveloppe de réponse (avec comparaison)
{
"data": [ ... ],
"total_cents": 1250000,
"total_count": 890,
"comparison": {
"from": "2025-05-01T00:00:00",
"to": "2025-06-01T00:00:00",
"data": [ ... ],
"total_cents": 1100000,
"total_count": 820,
"growth_pct": 13.6
}
}
growth_pct = variation en pourcentage. Si la période précédente est nulle : 0.0 si la période courante l'est aussi, sinon 100.0.
GET /admin/org/analytics/overview
Vue d'ensemble complète (sans comparaison).
{
"period": { "from": "2025-06-01T00:00:00", "to": "2025-06-30T23:59:59" },
"revenue": [
{ "tx_type": "debit_purchase", "tx_count": 450, "total_cents": 900000 }
],
"total_revenue_cents": 1250000,
"total_transactions": 890,
"top_products": [
{ "product_name": "Café", "tx_count": 320, "total_cents": 320000 }
],
"sites_revenue": [
{ "site_id": "uuid", "site_name": "Buvette Principale", "tx_count": 890, "total_cents": 1250000 }
],
"avg_transaction": {
"overall_cents": 1404,
"total_tx": 890,
"total_revenue_cents": 1250000,
"by_type": [
{ "tx_type": "debit_purchase", "avg_cents": 2000, "tx_count": 450, "total_cents": 900000 }
],
"by_site": [
{ "site_name": "Buvette Principale", "avg_cents": 1404, "tx_count": 890, "total_cents": 1250000 }
]
},
"product_categories": [
{ "category": "Boissons", "product_count": 12, "tx_count": 320, "total_cents": 320000 }
],
"hourly_distribution": [
{ "hour": 12, "tx_count": 120, "total_cents": 180000 }
],
"peak_activity": [
{ "hour": 12, "day_of_week": 2, "tx_count": 45, "total_cents": 67500 }
]
}
GET /admin/org/analytics/revenue-by-type
Revenus par type avec comparaison.
Élément data : { tx_type, tx_count, total_cents }
GET /admin/org/analytics/top-products
Top 20 produits avec comparaison.
Élément data : { product_name, tx_count, total_cents }
GET /admin/org/analytics/sites-revenue
Revenus par site avec comparaison.
Élément data : { site_id, site_name, tx_count, total_cents }
GET /admin/org/analytics/avg-transaction
Montant moyen par transaction (sans comparaison).
{
"overall_cents": 1404,
"total_tx": 890,
"total_revenue_cents": 1250000,
"by_type": [
{ "tx_type": "debit_purchase", "avg_cents": 2000, "tx_count": 450, "total_cents": 900000 }
],
"by_site": [
{ "site_name": "Buvette Principale", "avg_cents": 1404, "tx_count": 890, "total_cents": 1250000 }
]
}
GET /admin/org/analytics/product-categories
Répartition par catégorie. Retourne un tableau (pas d'enveloppe).
[
{ "category": "Boissons", "product_count": 12, "tx_count": 320, "total_cents": 320000 }
]
GET /admin/org/analytics/growth
Métriques de croissance (la période précédente est déduite automatiquement).
{
"current_period": {
"from": "2025-06-01T00:00:00", "to": "2025-06-30T23:59:59",
"transaction_count": 890, "revenue_cents": 1250000
},
"previous_period": {
"from": "2025-05-02T00:00:00", "to": "2025-05-31T23:59:59",
"transaction_count": 820, "revenue_cents": 1100000
},
"revenue_growth_pct": 13.6,
"transactions_growth_pct": 8.5,
"new_holders": 45,
"new_holders_previous": 40,
"new_holders_growth_pct": 12.5
}
GET /admin/org/analytics/peak-activity
Pics d'activité. Retourne un tableau trié par tx_count décroissant.
[
{ "hour": 12, "day_of_week": 2, "tx_count": 45, "total_cents": 67500 }
]
Voir aussi
- Statistiques — stats simples et export
- Logs & Audit