Historical Routes
RESTful API endpoints for querying historical time-series traffic data and temporal aggregations from TimescaleDB.
Base Pathโ
/api/historical
Endpoints Summaryโ
| Method | Endpoint | Description |
|---|---|---|
| GET | /traffic | Historical traffic data |
| GET | /weather | Historical weather data |
| GET | /air-quality | Historical AQI data |
| GET | /patterns | Historical patterns |
Endpointsโ
GET /api/historical/trafficโ
Get historical traffic metrics.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
roadSegment | string | No | Road segment ID |
from | string | Yes | Start date (ISO 8601) |
to | string | Yes | End date (ISO 8601) |
interval | string | No | Aggregation: hour, day, week |
Response:
{
"success": true,
"data": [
{
"timestamp": "2025-11-28T08:00:00.000Z",
"averageSpeed": 28.5,
"vehicleCount": 1250,
"congestionLevel": "high"
},
{
"timestamp": "2025-11-28T09:00:00.000Z",
"averageSpeed": 32.1,
"vehicleCount": 980,
"congestionLevel": "moderate"
}
],
"meta": {
"interval": "hour",
"dataPoints": 24
}
}
GET /api/historical/patternsโ
Get historical traffic pattern analysis.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
dayOfWeek | number | Day of week (0=Sunday) |
hourOfDay | number | Hour (0-23) |
roadSegment | string | Road segment ID |
Response:
{
"success": true,
"data": {
"averageSpeed": 28.5,
"averageVehicleCount": 1150,
"sampleCount": 52,
"standardDeviation": 5.2,
"percentiles": {
"p25": 24.0,
"p50": 28.5,
"p75": 33.0,
"p95": 42.0
}
}
}
Time Range Limitsโ
| Period | Max Range | Aggregation |
|---|---|---|
| Real-time | 24 hours | None |
| Short-term | 7 days | Hourly |
| Medium-term | 30 days | Daily |
| Long-term | 365 days | Weekly |
Related Documentationโ
- PostgresService - TimescaleDB queries
- Analytics Routes - Real-time analytics
- FusekiService - SPARQL historical