Get Dashboard Statistics
GET /api/dashboard
Retrieve aggregated statistics and analytics for the dashboard, including KPIs, recent tickets, and chart data for collection and dispatch trends.
Query Parameters
Filter statistics by collection center ID. If not provided, uses the active collection center from configuration.
Start date for filtering in DD/MM/YYYY format (e.g., “01/01/2026”)
End date for filtering in DD/MM/YYYY format (e.g., “31/12/2026”)
Filter by specific month (1-12)
Filter by specific year (e.g., 2026)
Filter statistics by a single generator ID
Filter statistics by multiple generator IDs (comma-separated)
Response
Total liters collected (sum of all ticket quantities)
Total liters dispatched (sum of all dispatch quantities)
Total number of collection tickets
Total number of unique generators (active clients)
Most recent 5 tickets (sorted by created_at DESC)
Daily aggregated data for volume trends chart
Example Request
Example Response
Date Filtering Logic
The dashboard endpoint supports flexible date formats and filtering:- Date formats: Accepts both DD/MM/YYYY and YYYY-MM-DD formats
- Range filtering: Use
dateFromanddateTofor custom ranges - Month/Year filtering: Use
monthandyearfor period filtering - Multiple filters: Can combine date ranges with month/year filters
EXTRACT() function for month/year filtering and TO_DATE() for parsing dates.
Chart Data Merging
ThechartData array merges collection (tickets) and dispatch data by date:
- Query tickets grouped by date →
litersIn - Query dispatches grouped by date →
litersOut - Merge into a single array where each date has both
litersInandlitersOutvalues
Error Responses
| Status | Description |
|---|---|
| 500 | Database query error |
Related
Dashboard Feature
Learn about the Dashboard UI
Tickets API
Retrieve raw ticket data
Dispatches API
Retrieve dispatch data
Configuration API
Manage active collection center