Analytics Routes
RESTful API endpoints for traffic analytics, statistics, summaries, and dashboard metrics.
Base Pathโ
/api/analytics
Endpoints Summaryโ
| Method | Endpoint | Description |
|---|---|---|
| GET | /summary | Get traffic summary |
| GET | /dashboard | Dashboard metrics |
| GET | /trends | Traffic trends |
| GET | /comparison | Period comparison |
Endpointsโ
GET /api/analytics/summaryโ
Get overall traffic summary.
Response:
{
"success": true,
"data": {
"totalCameras": 520,
"activeCameras": 485,
"totalAccidents": 12,
"activeAccidents": 3,
"averageSpeed": 35.5,
"congestionIndex": 0.42,
"airQuality": {
"averageAqi": 85,
"category": "Moderate"
},
"timestamp": "2025-11-29T10:30:00.000Z"
}
}
GET /api/analytics/dashboardโ
Get real-time dashboard metrics.
Response:
{
"success": true,
"data": {
"traffic": {
"currentFlow": 12500,
"change24h": "+5.2%",
"peakHour": "17:00-18:00"
},
"incidents": {
"active": 3,
"resolved24h": 8,
"averageResolutionTime": "45 min"
},
"environment": {
"aqi": 85,
"temperature": 32,
"humidity": 75
},
"alerts": [
{
"type": "accident",
"severity": "high",
"message": "Serious accident on Nguyen Hue"
}
]
}
}
GET /api/analytics/trendsโ
Get traffic trends over time.
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
period | string | 24h | Time period: 24h, 7d, 30d |
metric | string | speed | Metric: speed, volume, congestion |
Response:
{
"success": true,
"data": {
"metric": "speed",
"period": "24h",
"dataPoints": [
{ "time": "00:00", "value": 45.2 },
{ "time": "06:00", "value": 38.5 },
{ "time": "12:00", "value": 28.3 },
{ "time": "18:00", "value": 22.1 }
],
"average": 33.5,
"min": 22.1,
"max": 45.2
}
}
Related Documentationโ
- Historical Routes - Time-series data
- Pattern Routes - Congestion patterns
- DataAggregator - Data collection