Routing
Routes, turn-by-turn directions, distance matrices, the best order for stops, reachable areas and road closures.
Base URLhttps://makani-gke-eu.lamah.com
Before you start
Routing needs a plan that includes it and a key with a routing scope: routing:route for everything except the matrix (routing:matrix) and road closures (routing:read).
- Points are
{ latitude, longitude }. countryCodeis required on every routing request. It applies the country's road closures, is checked against the countries your key and your plan allow, and is recorded on usage. A request without it answers400 VALIDATION_FAILED.costingis the way of travel:autoby default, orbicycle,bus,motor_scooter,motorcycle,pedestrian,taxiortruck.language(ar,en) is the language of directions and of road closure names.
Route
A road route between two points, through up to 20 stops in via. The answer has distanceMeters, durationSeconds and shape, a polyline at six decimal places. closures.avoided lists the road closures the route went around.
routing:routecurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/route" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "from": { "latitude": 25.2854, "longitude": 51.531 }, "to": { "latitude": 25.3548, "longitude": 51.4816 } }'Turn-by-turn directions
The same route with every maneuver, banner text and voice instruction, in the OSRM route format that navigation libraries read. Send heading (degrees) on a reroute so the route keeps to the side of the road the vehicle is on.
In Flutter, the navigation package asks for directions itself and guides on the device: snapping, step advance, rerouting, voice and the camera.
routing:routecurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/directions" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "from": { "latitude": 25.2854, "longitude": 51.531 }, "to": { "latitude": 25.3548, "longitude": 51.4816 }, "language": "en" }'Other routes
Send alternatives (0 to 2, default 0) on a route or directions request to get that many other routes besides the best one, in an alternatives array, best first. Routing may find fewer, or none; between more than two points (with via stops) it finds none.
A request with other routes is billed as one request, whatever the number, as Google's Routes API bills them. Every new request is billed again: when a driver leaves the route and you ask for a new one, that is a new request.
Routing to an address's entrance
An end of a route can name one of our addresses by its code instead of coordinates: { "publicCode": "LY-F7P2F-3545" }, in the request's countryCode. The route then ends at the main entrance of the address's building, where a driver can stop, rather than at the middle of the building. When the building has no entrance on record, the route ends at the address's own point. Coordinates sent beside a code are ignored for that end. Plain coordinates are routed exactly as sent.
The answer says what was used, in addressEnds: for each end sent as a code, its publicCode, used (entrance or address) and the latitude and longitude the route ends at. It works on /v1/routing/route (also for via stops) and /v1/routing/directions, and costs the same one request. A code that is not a published address answers 404 ADDRESS_NOT_FOUND and is not charged.
Distance matrix
Distances and durations from every source to every target, up to 2,500 pairs in one request. A pair with no route does not fail the request: its cell has distanceMeters: null, durationSeconds: null and a reason. Each cell carries distanceMeters and durationSeconds, the units a route answers in; distance (kilometers) and time are still sent and are deprecated.
answeredCells is what the request is billed: one unit per answered pair.
routing:matrixcurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/matrix" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "sources": [ { "latitude": 25.2854, "longitude": 51.531 } ], "targets": [ { "latitude": 25.3548, "longitude": 51.4816 }, { "latitude": 25.3212, "longitude": 51.5301 } ] }'Best stop order
For a driver with several deliveries, or a technician with several visits: you send the stops in any order and get them back in the order to drive.
Puts 2 to 25 stops in the order that takes the least time and returns the route through them. order holds indexes into your stops, in visiting order, and legs has one entry per hop. Without to the trip returns to from. For a one-way run that does not come back, such as a delivery round, send roundTrip: false: the trip ends at whichever stop is best visited last. To end at a place of your choosing, send it as to.
Each stop is one unit.
routing:routecurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/optimize" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "from": { "latitude": 25.2854, "longitude": 51.531 }, "stops": [ { "latitude": 25.3212, "longitude": 51.5301 }, { "latitude": 25.2632, "longitude": 51.5561 }, { "latitude": 25.2919, "longitude": 51.4963 } ] }'Reachable area
For questions such as which customers a branch can serve within 15 minutes, or how far a courier gets in 10: the answer is an area you can draw on a map or test a point against.
The area that can be reached from origin within each contour, as GeoJSON. Send one to four contours, each { minutes } (60 at most) or { kilometers } (50 at most). The answer has one feature per contour, in request order, with coordinates longitude first.
Each contour is one unit.
routing:routecurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/isochrone" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "origin": { "latitude": 25.2854, "longitude": 51.531 }, "contours": [ { "minutes": 10 }, { "kilometers": 5 } ] }'Road closures
When a road is closed, routes go around it from the second the closure starts. To draw the closed roads on your own map, read them as GeoJSON lines. This endpoint is never charged. status is active (default) or scheduled, bbox is minLongitude,minLatitude,maxLongitude,maxLatitude, and at answers for another moment.
routing:readcurl "https://makani-gke-eu.lamah.com/v1/routing/closures?countryCode=QA&bbox=51.4%2C25.2%2C51.6%2C25.4&language=en" \ -H "x-api-key: $MAKANI_API_KEY"When a closure leaves no way through, a route request is refused with one of two errors. details.closures names the closures, and details.messages has the message in Arabic and English:
- 422
ROUTE_BLOCKED_BY_CLOSURENo route avoids the road closures in the way. - 422
ROUTE_ENDPOINT_ON_CLOSED_ROADThe origin, the destination or a stop is itself on a closed road.details.endpointsays which.
Snap a recorded trace to the road
Send 2 to 2,000 recorded GPS points in order and get the road they followed as shape.
routing:routecurl -X POST "https://makani-gke-eu.lamah.com/v1/routing/trace" \ -H "x-api-key: $MAKANI_API_KEY" \ -H "content-type: application/json" \ -d '{ "countryCode": "QA", "points": [ { "latitude": 25.2854, "longitude": 51.531 }, { "latitude": 25.2861, "longitude": 51.5296 } ] }'When there is no answer
When routing is unavailable, a request fails with 503 ROUTING_UNAVAILABLE and a Retry-After header; it is never charged. For a route or a matrix you can send allowEstimate: true to get a straight-line estimate instead: it is marked estimateDegraded: true, has no shape, and is not charged.
- 400
VALIDATION_FAILEDA parameter is missing or invalid.details.errorslists each failing field with its messages, andmessagejoins them. - 400
COUNTRY_CODE_CONFLICTThe path, the query and the body name different countries. Send onecountryCode. - 403
API_KEY_COUNTRY_DENIEDThe key is not enabled for this country, whether the request names it in the path, the query or the body. - 404
ADDRESS_NOT_FOUNDAn end'spublicCodeis not a published address incountryCode. Never charged. - 422
ROUTE_NOT_FOUNDThere is no road route between the points. - 422
TRACE_NOT_MATCHEDThe recorded points do not follow any road. - 400
MATRIX_SIZE_INVALIDThe matrix has no pair, or more than 2,500. - 400
OPTIMIZE_STOPS_INVALIDFewer than 2 stops, or more than 25. - 400
ISOCHRONE_CONTOURS_INVALIDNot one to four contours, or a contour without exactly one of minutes and kilometers. - 503
ROUTING_UNAVAILABLERouting cannot answer now. WaitRetry-Afterseconds. Never charged.