Documentation menu
POST/trace_route
Access and price
| Auth | An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused. |
|---|---|
| Price | 1 call per started block of 50 shape points or 300 encoded-polyline characters, whichever is more. Class: standard, or premium for truck and ADR work. Published as unit_rules.trace in /pricing.json. |
| Premium | When the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true |
What it does
Map matching to a route.
An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 1 call per started block of 50 shape points or 300 encoded-polyline characters, whichever is more.
Call it
curl -fsS -X POST "https://api.mapmap.ai/trace_route" \
-H "Authorization: Bearer $MAPMAP_KEY" \
-H "Content-Type: application/json" \
-d '{"costing":"auto","shape":[{"lat":51.5074,"lon":-0.1278},{"lat":51.509,"lon":-0.13}],"shape_match":"map_snap"}'Request body
application/json
Valhalla trace request JSON: shape (points) or encoded_polyline, costing, optional shape_match and costing_options
Example: From website/public/docs/analysis.md:467
{
"costing": "auto",
"shape": [
{
"lat": 51.5074,
"lon": -0.1278
},
{
"lat": 51.509,
"lon": -0.13
}
],
"shape_match": "map_snap"
}Responses
| Field | Type | Required | Description |
|---|---|---|---|
| alternates | object[] | no | Alternative matches, when the engine returns any. |
| trip | object | no | The Valhalla trip along the matched path, shaped as on
POST /route. |
Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /trace_route with the request example; lists trimmed to their first items
{
"trip": {
"language": "en-US",
"legs": [
{
"maneuvers": [
{
"begin_shape_index": 0,
"begin_street_names": [
"Trafalgar Square",
"A4"
],
"end_shape_index": 19,
"instruction": "Drive northwest on Trafalgar Square/A4. Continue on A4.",
"length": 0.164,
"street_names": [
"A4"
],
"time": 20.728,
"travel_mode": "drive",
"travel_type": "car",
"type": 1,
"verbal_multi_cue": true,
"verbal_post_transition_instruction": "Continue on A4 for 200 meters.",
"verbal_pre_transition_instruction": "Drive northwest on Trafalgar Square, A4. Then, in 200 meters, Turn right onto Cockspur Street.",
"verbal_succinct_transition_instruction": "Drive northwest. Then, in 200 meters, Turn right onto Cockspur Street."
},
{
"begin_shape_index": 19,
"end_shape_index": 26,
"instruction": "Turn right onto Cockspur Street.",
"length": 0.036,
"street_names": [
"Cockspur Street"
],
"time": 5.7,
"travel_mode": "drive",
"travel_type": "car",
"type": 10,
"verbal_multi_cue": true,
"verbal_post_transition_instruction": "Continue for 40 meters.",
"verbal_pre_transition_instruction": "Turn right onto Cockspur Street. Then Bear right onto Pall Mall East.",
"verbal_succinct_transition_instruction": "Turn right. Then Bear right onto Pall Mall East.",
"verbal_transition_alert_instruction": "Turn right onto Cockspur Street."
}
],
"shape": "qdwfaB|_yF{AnCyA|Dk@pCc@`EYrGOhFOhFKdCIhBIhAg@`Cs@jBWtIc@dJ}ArWWlEGhAWnFaAnP}AlAaAr@cAF{@RaAJgAMuDgBgCqJqGmU}BnByNtM{T`KQyA_BkO",
"summary": {
"cost": 113.845,
"has_ferry": false,
"has_highway": false,
"has_toll": false,
"length": 0.348,
"max_lat": 51.508881,
"max_lon": -0.128015,
"min_lat": 51.507289,
"min_lon": -0.130368,
"time": 51.01
}
}
],
"locations": [
{
"lat": 51.5074,
"lon": -0.1278,
"original_index": 0,
"type": "break"
},
{
"lat": 51.509,
"lon": -0.13,
"original_index": 1,
"type": "break"
}
],
"status": 0,
"status_message": "Found route between points",
"summary": {
"cost": 113.845,
"has_ferry": false,
"has_highway": false,
"has_toll": false,
"length": 0.348,
"max_lat": 51.508881,
"max_lon": -0.128015,
"min_lat": 51.507289,
"min_lon": -0.130368,
"time": 51.01
},
"units": "kilometers"
}
}application/problem+json · Problem
unauthorized); the body carries signup, docs and a one-call hint for a free keyapplication/problem+json · Problem
X-PAYMENT). Not problem+jsonapplication/json · X402PaymentRequired
scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)application/problem+json · Problem
text/plain
rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)application/problem+json · Problem
application/problem+json · Problem
request-timeout)application/problem+json · Problem
Error bodies follow the shared problem model documented on API conventions.
Also under Routing
Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_trace_route