βHow to build your first route request in JSONβ
We want to ask the API:
βGive me the best route by car from point A to point B.β
To do this, weβll build a small JSON file that the API understands.
Start by saying what kind of vehicle you're using.
In our case, we use a car:
"routingVehicleProfile": {
"transportMode": "CAR"
}π This tells the API to compute a route suitable for a car.
You can ask the API to return useful data, such as:
POLYLINEβ the route on the mapROUTESHEETβ step-by-step instructions (like GPS)
We add them in a list:
"options": ["POLYLINE", "ROUTESHEET"]Now give the GPS positions for the start and end of the trip.
Each point must include:
lonβ longitudelatβ latitudespeedβ estimated speed at that momenttimeβ timestamp in milliseconds (you can copy/paste this part)
"destinations": [
{
"coordinateSat": {
"lon": 2.3488,
"lat": 48.8534,
"speed": 20.0,
"time": 1720519200000
}
},
{
"coordinateSat": {
"lon": 2.3600,
"lat": 48.8580,
"speed": 35.0,
"time": 1720519260000
}
}
]Now put all the pieces together:
{
"geoserver": "osm",
"routingVehicleProfile": {
"transportMode": "CAR"
},
"options": ["POLYLINE"],
"destinations": [
{
"coordinateSat": {
"lon": 2.3488,
"lat": 48.8534,
"speed": 20.0,
"time": 1720519200000
}
},
{
"coordinateSat": {
"lon": 2.3600,
"lat": 48.8580,
"speed": 35.0,
"time": 1720519260000
}
}
]
}1. Open your favorite API testing tool (e.g. Postman, Insomnia, or curl).
2. Paste this JSON in the body of a POST request.
3. Send the request to your TraceRoute API endpoint.
4. Read the response: you'll get a map polyline and a route sheet.
Donβt worry too much about
speedortimevalues β just copy them from examples for now.You can add more points to create a route with stops.
You can always test with
transportMode: "CAR"first.