Maps, search & Studio APIs
Build with maps and location data
Authentication and errors
Send your key in the Authorization: Bearer header. Coordinates use [longitude, latitude]. Set OSRM_API_KEY in your server environment; never expose a secret in browser code.
401: missing or invalid key · 403: scope denied · 402: insufficient credits · 429: rate limit · 502/503: upstream unavailable. Check the HTTP status before using a response.
409: revision conflict. Read the latest resource and reconcile changes before retrying.
Fuel Estimate API
Estimate fuel volume and trip value from distance, loaded weight, observed empty/full consumption and your fuel price. Use it alone or include fuel in a Truck request.
- Request credits
- 1
- Required scopes
route
Standalone: 1 credit; optional Truck estimate is included in the route price and uses the returned road distance. Requires empty/full calibration at comparable operating conditions. Linear load interpolation; speed, slopes, traffic, wind and idling are not modeled. No validated error percentage. Prices are supplied by you; no currency conversion.
POST /api/v1/fuel/estimate
distance_km * | number | min: 0 · max: 100000 |
|---|---|---|
loaded_weight_t * | number | min: 0.001 · max: 100 |
fuel * | object | |
fuel.empty_weight_t * | number | min: 0.001 · max: 100 |
fuel.full_weight_t * | number | min: 0.001 · max: 100 |
fuel.empty_l_per_100km * | number | min: 0.001 · max: 200 |
fuel.full_l_per_100km * | number | min: 0.001 · max: 200 |
fuel.price_per_liter * | string | maxLength: 30 |
fuel.currency * | string | |
How the fuel estimate works
Supply empty and fully loaded gross weights, observed consumption in L/100 km at both weights, actual loaded gross weight, distance, price per litre and currency. Use measurements from comparable conditions. The loaded weight must stay within your calibration range; the full-load rate cannot be below the empty rate.
load_ratio = (loaded_weight_t - empty_weight_t) / (full_weight_t - empty_weight_t)
L_per_100km = empty_l_per_100km + load_ratio * (full_l_per_100km - empty_l_per_100km)
fuel_liters = distance_km * L_per_100km / 100
fuel_cost = fuel_liters * price_per_literIllustrative inputs, not measured vehicle data: empty 12 t at 20 L/100 km; full 40 t at 34 L/100 km; actual 26 t; distance 500 km; price 1.10 AZN/L. Result: 27 L/100 km, 135 L and 148.50 AZN. Decimal output precision is not prediction accuracy.
For Truck Routing, add this optional fuel object to the existing request. Loaded weight comes from vehicle.weight_t and distance from the returned road route; do not send a separate fuel distance or loaded weight. Without fuel, the route response stays unchanged. Standalone REST and MCP estimates cost 1 credit; adding fuel to Truck costs no extra credits.
{
"fuel": {
"empty_weight_t": 12,
"full_weight_t": 40,
"empty_l_per_100km": 20,
"full_l_per_100km": 34,
"price_per_liter": "1.10",
"currency": "AZN"
}
}This is a linear estimate based on your calibration. Speed, road gradient, traffic, wind, idling and driving style are excluded. No validated error percentage is available. Fuel prices are supplied by you; currencies are not converted. Results are estimates, not a payment or a guaranteed fuel bill.
MCP: estimate_fuel
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/fuel/estimate" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"distance_km":500,"loaded_weight_t":26,"fuel":{"empty_weight_t":12,"full_weight_t":40,"empty_l_per_100km":20,"full_l_per_100km":34,"price_per_liter":"1.10","currency":"AZN"}}'method: user_calibrated_linear_load_v1
estimated: true
distance_km
loaded_weight_t
consumption_l_per_100km
fuel_liters
fuel_cost.amount (decimal string)
fuel_cost.currency
accuracy.validated_error_percent: null
basis
exclusions[]Truck Routing API
Plan truck routes within and across countries on connected roads. Send the dimensions and loaded weight of the vehicle with each request.
- Request credits
- 1 credit per started block of 10 input points, including origin and destination.
- Required scopes
route
2–20 points, subject to plan limits; up to 1,000 km, snapping within 250 m and 10 requests/minute/key. Dimensions are in metres, loaded and heaviest-axle weight in metric tonnes; axle count includes trailers. Routing uses static road restrictions. Set hazmat=true to apply mapped general hazardous-material restrictions. Classification-specific rules, conditional restrictions and live traffic are not included; verify current rules and posted signs.
Coverage: mapped roads worldwide. A connected road network suitable for the vehicle is required. Road data and restriction detail vary by location.
POST /api/v1/truck/route
points * | array | |
|---|---|---|
vehicle * | object | |
vehicle.height_m * | number | min: 0.5 · max: 10 |
vehicle.width_m * | number | min: 0.5 · max: 5 |
vehicle.length_m * | number | min: 1 · max: 35 |
vehicle.weight_t * | number | min: 0.1 · max: 100 |
vehicle.axle_load_t * | number | min: 0.1 · max: 40 |
vehicle.axle_count * | integer | min: 2 · max: 20 |
vehicle.hazmat | boolean | |
fuel | object | |
fuel.empty_weight_t * | number | min: 0.001 · max: 100 |
fuel.full_weight_t * | number | min: 0.001 · max: 100 |
fuel.empty_l_per_100km * | number | min: 0.001 · max: 200 |
fuel.full_l_per_100km * | number | min: 0.001 · max: 200 |
fuel.price_per_liter * | string | maxLength: 30 |
fuel.currency * | string | |
How the fuel estimate works
For Truck Routing, add this optional fuel object to the existing request. Loaded weight comes from vehicle.weight_t and distance from the returned road route; do not send a separate fuel distance or loaded weight. Without fuel, the route response stays unchanged. Standalone REST and MCP estimates cost 1 credit; adding fuel to Truck costs no extra credits.
{
"fuel": {
"empty_weight_t": 12,
"full_weight_t": 40,
"empty_l_per_100km": 20,
"full_l_per_100km": 34,
"price_per_liter": "1.10",
"currency": "AZN"
}
}This is a linear estimate based on your calibration. Speed, road gradient, traffic, wind, idling and driving style are excluded. No validated error percentage is available. Fuel prices are supplied by you; currencies are not converted. Results are estimates, not a payment or a guaranteed fuel bill.
MCP: estimate_fuel
Plan cross-border truck routes
Send the origin, destination and any stops in order, along with the loaded vehicle dimensions, gross weight, heaviest axle load and total axle count. Truck Routing can cross country borders where the mapped road network has a connected route suitable for that vehicle.
Try the Strasbourg–Kehl example for a loaded 30-tonne vehicle travelling from France to Germany. Replace the points and vehicle details with your own when testing your routes.
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/truck/route" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"points":[[7.7707,48.5761],[7.8214,48.5783]],"vehicle":{"height_m":4,"width_m":2.55,"length_m":16.5,"weight_t":30,"axle_load_t":10,"axle_count":5}}'profile: truck
vehicle
routes[].distance (m)
routes[].duration (estimated seconds)
routes[].geometry (GeoJSON LineString)
waypoints[].location
waypoints[].distance (m)- HTTP 403 ·
truck_plan_point_limit - The selected plan does not allow this many stops in one request. Send fewer points or review the plan limit.
- HTTP 422 ·
truck_no_route - A route suitable for this vehicle could not be calculated. Check the stops and the actual vehicle details.
- HTTP 422 ·
truck_no_nearby_road - A stop could not be matched to a suitable road within 250 m. Try the vehicle entrance or the road used to reach it.
- HTTP 422 ·
truck_outside_coverage - At least one stop is outside the available Truck Routing coverage.
- HTTP 422 ·
truck_route_too_long - The request exceeds the 1,000 km limit. Use separate road legs that meet at reachable stops.
Natural Language Search
Find places using a short English query.
- Request credits
- 2
- Required scopes
geocode + places
English category + near/in + place; optional radius 100–5000 m. Six categories, up to ten candidates. No ratings, prices, open-now or live availability. Two credits, including an empty successful result.
POST /api/v1/search/natural
q * | string | maxLength: 1000 |
|---|---|---|
ai | boolean | default: false |
center | array | |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/search/natural" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q":"cafes near Berlin within 2 km"}'intent
places[].distance_meters
places[].details
interpretation: constrained_english_grammar
exhaustive: falsePlace details
Read source attributes from a retrieved suggestion or route search.
- Request credits
- 1
- Required scopes
places
One credit with places scope. Read one object by its search result ID; source cache lasts one hour. Missing phone, website, opening hours and accessibility remain null. Source update time is the object edit time, not business verification. No live opening status. 20 calls/min/key; source cache misses share 30/min.
POST /api/v1/places/details
id * | string | maxLength: 24 |
|---|
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/places/details" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id":"osm:N:123"}'place.details.phone
place.details.website
place.details.opening_hours
place.details.wheelchair
place.details.observed_at
place.details.source_updated_at
place.details.open_now: nullText-to-style preview
Describe palette and layer changes, review the map, then apply.
- Request credits
- 0
- Required scopes
studio
English commands separated by semicolons. Presets, hex colors and layer visibility only. Preview never saves or publishes; Apply enters the existing draft and autosave flow.
POST /api/v1/studio/preview
prompt * | string | maxLength: 1000 |
|---|---|---|
ai | boolean | default: false |
design | object | |
design.preset * | string | light | dark | navigation | minimal |
design.colors * | object | |
design.visible * | object | |
design.center * | array | |
design.zoom * | number | min: 0 · max: 20 |
design.overlays * | array | |
design.datasets | array | |
design.allowedOrigins | array | |
design.brand | string | |
design.interactions | object | |
design.categories | object | |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/studio/preview" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"dark; water #123456; hide buildings"}'design
changes[]
saved: false
method: explicit_style_commandsStatic Maps API
Export styled maps as PNG images for reports and applications.
- Request credits
- 4
- Required scopes
maps
Four palettes: light, dark, navigation and minimal. Images are 128–512 px per side; zoom is 1–14. Simplified rendering includes source attribution; custom Studio layers and effects are not rendered.
POST /api/v1/maps/static
center * | array | |
|---|---|---|
zoom | integer | min: 1 · max: 14 · default: 12 |
width | integer | min: 128 · max: 512 · default: 512 |
height | integer | min: 128 · max: 512 · default: 512 |
style | string | light | dark | navigation | minimal |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/maps/static" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"center":[13.405,52.52],"zoom":12,"width":512,"height":512,"style":"light"}' \
--output map.pngContent-Type: image/pngDataset Query API
Find nearby features in your own uploaded geographic datasets.
- Request credits
- 1
- Required scopes
maps
Only datasets owned by the key owner are accessible. Radius: 0–50,000 m; limit: 1–50. Results contain nearest points and estimated local distances, not road distance or original full geometries. Empty successful results also cost one credit.
POST /api/v1/maps/datasets/{id}/query
point * | array | |
|---|---|---|
radius | number | min: 0 · max: 50000 · default: 0 |
limit | integer | min: 1 · max: 50 · default: 10 |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/maps/datasets/$DATASET_ID/query" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"point":[2.3522,48.8566],"radius":1000,"limit":10}'type: FeatureCollection
features[].geometry.type: Point
features[].properties
returnedSearch Along Route API
Discover useful stops and compare their additional driving time.
- Request credits
- 14
- Required scopes
places + route
Driving routes up to 200 km. Five sampled locations and at most eight candidate detours; discovery is not exhaustive. Categories: fuel, charging_station, restaurant, cafe, parking, pharmacy. No live traffic or charger availability.
POST /api/v1/places/along-route
start * | array | |
|---|---|---|
end * | array | |
category * | string | fuel | charging_station | restaurant | cafe | parking | pharmacy |
max_detour_seconds | number | min: 0 · max: 1800 · default: 600 |
limit | integer | min: 1 · max: 8 · default: 5 |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/places/along-route" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"start":[13.405,52.52],"end":[13.3777,52.5163],"category":"cafe","max_detour_seconds":600,"limit":5}'places[]
baseline.duration_seconds
baseline.distance_meters
discovery
duration_modelStructured Geocoding API
Search addresses with street, city, postcode and country components.
- Request credits
- 1
- Required scopes
geocode
Provide street, city or postcode. Country codes contain two letters; other fields allow 100 characters. Components form a text search. Matched/different/missing comparisons and source precision are not guaranteed address validation.
POST /api/v1/search/structured
housenumber | string | maxLength: 100 |
|---|---|---|
street | string | maxLength: 100 |
city | string | maxLength: 100 |
state | string | maxLength: 100 |
postcode | string | maxLength: 100 |
countrycode | string | maxLength: 2 |
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/search/structured" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"street":"Friedrichstraße","city":"Berlin","countrycode":"DE"}'features[].id
features[].address
features[].precision
features[].match.components
features[].precision_basis
search_method: composed_address_querySuggest & Retrieve API
Build place search with suggestions and a secure retrieval step.
- Request credits
- 1 + 1
- Required scopes
geocode
Each suggest and retrieve request costs one credit. Query: 1–200 characters. Retrieval tokens expire after 10 minutes and belong to the key owner. Retrieve returns the signed suggestion snapshot, not a fresh lookup.
POST /api/v1/search/suggest
q * | string | maxLength: 200 |
|---|
POST /api/v1/search/retrieve
token * | string | maxLength: 16384 |
|---|
curl --fail-with-body -X POST "https://osrmroute.com/api/v1/search/suggest" \
-H "Authorization: Bearer $OSRM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q":"Paris"}'suggestions[].id
suggestions[].name
suggestions[].address
suggestions[].token
expires_in_seconds: 600
retrieve → place, retrieval: signed_suggestion_snapshotcurl --fail-with-body -X POST "https://osrmroute.com/api/v1/search/retrieve" \
-H "Authorization: Bearer $OSRMROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"token":"TOKEN_FROM_SUGGEST"}'Studio API
Manage map styles, datasets and publication from your application.
- Request credits
- 0
- Required scopes
studio
Explicit studio scope is required, including for unrestricted keys. GET lists owned styles or dataset metadata; POST manages resources. Styles use revisions and publication confirmation. Datasets support create/delete, not in-place editing. Limits: 30 reads or 5 writes/minute/key; workspace quotas apply.
GET / POST /api/v1/studio/{resource}
action * | string | create | save | autosave | duplicate | restore | publish | unpublish | delete |
|---|---|---|
id | string | |
revision | integer | |
name | string | maxLength: 80 |
design | object | |
design.preset * | string | light | dark | navigation | minimal |
design.colors * | object | |
design.visible * | object | |
design.center * | array | |
design.zoom * | number | min: 0 · max: 20 |
design.overlays * | array | |
design.datasets | array | |
design.allowedOrigins | array | |
design.brand | string | |
design.interactions | object | |
design.categories | object | |
data | object | |
confirmPublic | boolean | |
confirmDelete | boolean | |
version | integer | |
curl --fail-with-body "https://osrmroute.com/api/v1/studio/styles" \
-H "Authorization: Bearer $OSRM_API_KEY"GET styles → styles[]
GET datasets → datasets[]styles · create | name, design |
|---|---|
styles · save / autosave | id, revision, name, design |
styles · duplicate | id, revision, name |
styles · restore | id, revision, version |
styles · publish | id, revision, confirmPublic: true |
styles · unpublish / delete | id, revision |
datasets · create | name, data: GeoJSON FeatureCollection |
datasets · delete | id, confirmDelete: true |
{
"action": "create",
"name": "Berlin",
"design": {
"preset": "light",
"colors": {
"land": "#f1f3f5",
"water": "#a9d8ed",
"park": "#c9dfc6",
"road": "#ffffff",
"highway": "#edc779",
"building": "#d9dee3",
"label": "#334155"
},
"visible": {
"roads": true,
"buildings": true,
"parks": true,
"labels": true,
"pois": true,
"boundaries": true
},
"center": [
13.405,
52.52
],
"zoom": 11,
"overlays": []
}
}{
"action": "create",
"name": "Paris places",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Paris"
},
"geometry": {
"type": "Point",
"coordinates": [
2.3522,
48.8566
]
}
}
]
}
}Map styles and vector tiles
Load public basemaps or published styles in MapLibre. Public requests need no API key and use zero credits. Use the tile URLs supplied by the style and preserve attribution.
light · dark · navigation · minimal
GET /api/basemaps/{style}GET /api/map-styles/{id}GET /api/map-styles/{id}/tiles/{dataset}/{z}/{x}/{y}GET /api/private-maps/{id}GET /api/private-maps/{id}/tiles/{dataset}/{z}/{x}/{y}
Server-to-server access to the current saved draft. Send Authorization: Bearer with a live key allowing maps, owned by this workspace. Keep the key on your backend and authenticate your own users before proxying style and tile requests. Do not embed the key in a browser or mobile app. Revoking the key blocks future requests.
Public styles and tiles use no key or credits. Published styles and tiles follow Studio publication and origin settings. Use the tile URLs returned by the style. Private style and tile requests share 300 requests per minute per key and consume no credits. Keep the map attribution visible.
curl --fail-with-body "https://osrmroute.com/api/basemaps/light"
curl --fail-with-body "https://osrmroute.com/api/private-maps/YOUR_DRAFT_ID" \
-H "Authorization: Bearer $OSRMROUTE_API_KEY"