Route between two points along roads

shortest_pathfreeInput: bounding boxOutput: GeoJSON

Computes a route over the real OSM road graph inside the chosen bounding box: the network is loaded from the database, clipped to the box and traversed with the A* algorithm, so the route never leaves the box. Modes: driving (one-way streets are honoured, including untagged roundabouts) and walking. The points are snapped to the nearest network node no farther than 500 m away, and the offset is shown in the response. The bounding box for a route is up to 400 km²; if the box or the network inside it is above the ceiling, the database did not answer or the computation did not fit the budget, a straight line is returned marked straight_line_fallback with the reason named. If there are no roads in the box, a point lies off the network or the network is disconnected — an honest refusal with no line.

Route between two points along roads — reference frame E1: a sample result on OpenStreetMap data
reference frame E1 · 5.6 km² · 1 features · 73 ms · OSM data of 2026-10-26 · parameters: from_lon=37.605, from_lat=55.745, to_lon=37.635, to_lat=55.757, mode=car

Parameters and limits

API nameTypeRequiredDefaultRange or allowed values
from_lonnumberyes—-180 – 180
from_latnumberyes—-90 – 90
to_lonnumberyes—-180 – 180
to_latnumberyes—-90 – 90
modeone of the listed valuesnocarcar | foot

The table is generated from the tool's own parameter contract: API names, types, defaults and the ranges its validator accepts.

What matters

Input, output and limits

The input is a rectangular bounding box in WGS84 plus one of nine data layers; some tools also take a point. The output is GeoJSON, JSON metrics or a GeoTIFF.

LayerWhat it holds
buildingsbuildings
roadsroads and streets
poipoints of interest: services, shops, tourism
waterwater bodies
green_areasgreen areas: parks, forests, lawns
railwaysrailways
boundariesadministrative boundaries
landuseland use
waterwayswaterways

Every tool in the section is free. The bounding box may cover up to 100 km². Rate limits are 10 requests per minute per tool run and 30 requests per minute for reading the catalogue. Without signing in you get up to 10 successful calculations a day; after that the service asks you to register and answers 402 with the code login_required. A box larger than the allowed area is also 402, and an unknown tool id is 404.

When the API refuses

CodeReason
400A parameter failed the tool's own check (the answer carries a validation_errors list) or the bbox does not hold four numbers.
402The bounding box is larger than 100 km² — or a visitor who is not signed in has used up 10 calculations for the day and the answer asks them to sign in (login_required).
403Access guard: every tool is free today, so this refusal reaches nobody.
404There is no tool with that identifier.
429Rate limit exceeded: 10 requests per minute per tool run.

Calculate right here

The map appears here once the page has loaded. Without JavaScript you can still order the calculation with the API example below.

Clicking the map sets a point: from, to.

Calculation frame, WGS84

Access

The tool is free. Visitors who are not signed in get 10 calculations a day; after signing in there is no daily cap. The bounding box may cover up to 100 km². OpenStreetMap data: snapshot of 2026-10-26.

Example call

curl -X POST https://osm2cdr.com/api/geo-analysis/shortest_path \
  -H 'Content-Type: application/json' \
  -d '{"bbox":[37.6,55.74,37.64,55.76],"params":{"from_lon":37.605,"from_lat":55.745,"to_lon":37.635,"to_lat":55.757,"mode":"car"}}'

The same in Python

import requests

r = requests.post(
    "https://osm2cdr.com/api/geo-analysis/shortest_path",
    json={'bbox': [37.6, 55.74, 37.64, 55.76], 'params': {'from_lon': 37.605, 'from_lat': 55.745, 'to_lon': 37.635, 'to_lat': 55.757, 'mode': 'car'}},
)
print(r.json()["meta"])

Full parameter schema: GET /api/geo-analysis/shortest_path/schema

Example response

{
  "tool": "shortest_path",
  "meta": {
    "elapsed_ms": 73,
    "feature_count": 1,
    "method": "network",
    "data_snapshot": "2026-10-26"
  },
  "result": {
    "feature_count": 1,
    "geometry_type": "LineString",
    "properties": {
      "distance_m": 3361.42,
      "method": "network"
    }
  }
}

The numbers come from the run that baked the sample above. A live answer also carries meta.quota — how many calculations the visitor has left for today. The response is shown as an excerpt; the full result is larger.