Routing Routes
RESTful API endpoints for turn-by-turn navigation and route optimization using OSRM (Open Source Routing Machine).
Base Path
/api/routing
Endpoints Summary
| Method | Endpoint | Description |
|---|---|---|
| GET | /directions | Get turn-by-turn directions |
| GET | /alternatives | Get alternative routes |
| GET | /matrix | Distance/time matrix |
| GET | /optimize | Route optimization (TSP) |
Endpoints
GET /api/routing/directions
Get turn-by-turn directions between two points.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
origin | string | Yes | Start: lat,lon |
destination | string | Yes | End: lat,lon |
profile | string | No | driving, cycling, walking |
alternatives | boolean | No | Include alternatives |
Response:
{
"success": true,
"data": {
"routes": [
{
"distance": 5420,
"duration": 845,
"geometry": "encoded_polyline_string",
"legs": [
{
"steps": [
{
"instruction": "Head north on Nguyen Hue",
"distance": 250,
"duration": 45,
"maneuver": "depart"
},
{
"instruction": "Turn right onto Le Loi",
"distance": 800,
"duration": 120,
"maneuver": "turn-right"
}
]
}
]
}
],
"waypoints": [
{ "name": "Start", "location": [106.70, 10.77] },
{ "name": "End", "location": [106.75, 10.80] }
]
}
}
GET /api/routing/matrix
Get distance/duration matrix for multiple points.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
origins | string | Yes | Origin points: lat1,lon1;lat2,lon2 |
destinations | string | Yes | Destination points |
Response:
{
"success": true,
"data": {
"durations": [
[0, 600, 900],
[650, 0, 450],
[850, 400, 0]
],
"distances": [
[0, 3500, 5200],
[3800, 0, 2800],
[5000, 2600, 0]
]
}
}
Related Documentation
- Geocoding Routes - Address lookup
- TrafficMaestroAgent - Traffic-aware routing