Routes and profiles
GET /v1/route answers the fastest way from one point to another for one mode of travel: how far, how long, and the path. Each mode — a profile — is its own network with its own speeds and its own rules about which way a road may be used, so a walking route is not a driving route at a slower pace.
curl -G "https://api.oslew.com/v1/route" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'from=19.4406,-99.2047' \
--data-urlencode 'to=19.4326,-99.1332' \
--data-urlencode 'geometry=false'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.route("19.4406,-99.2047", "19.4326,-99.1332", geometry=False)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.route("19.4406,-99.2047", "19.4326,-99.1332", { geometry: false });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"from": [
19.4406,
-99.2047
],
"to": [
19.4326,
-99.1332
],
"snapped_from": {
"from": 394836,
"to": 394840,
"frac": 0.05159010871941542,
"lat": 19.440242113128892,
"lon": -99.20471337400338,
"distance_m": 39.819960107330104,
"time_ds": 28,
"len_m": 39,
"two_way": false
},
"snapped_to": {
"from": 355496,
"to": 355490,
"frac": 0.16199866758190418,
"lat": 19.43200133133587,
"lon": -99.13329035902773,
"distance_m": 67.23995201279342,
"time_ds": 110,
"len_m": 92,
"two_way": false
},
"found": true,
"distance_m": 9269,
"duration_s": 695.2,
"nodes": 165,
"settled": 431,
"geometry": [],
"engine": "base/hierarchy",
"provenance": {
"name": "overture-transportation",
"release": "2026-08-19.0",
"license": "ODbL-1.0"
},
"took_us": 932
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Museo Soumaya to the Zócalo by car: 9,269 m in 695.2 s, a little under twelve minutes. The request asked forgeometry=false, so geometry is empty — but nodes still says the path has 165 points, and nothing else in the answer changes. Leave the geometry out whenever you only need the numbers; it is most of the bytes of a long route.
Parameters
| Parameter | Default | Is |
|---|---|---|
from, to | required | Each a lat,lon string. Either may be anywhere within about 9 km of a road in the profile's network. |
profile | driving | driving, walking, cycling, rail, or live — driving on live traffic weights. |
traffic | none | live is the same as profile=live, and is refused for any profile but driving. See live traffic. |
geometry | true | Whether to return the path. false leaves geometry empty and changes nothing else. |
Four profiles, four networks
Every profile is built from the same road data, but it reads it differently: which classes of road it may use, how fast it goes on each, and which access rules bind it. That is why the same two points snap to different places and come back with different distances, not only different times.
| Profile | Uses | Speed | Direction |
|---|---|---|---|
driving | Roads, from motorways to alleys. Access rules for vehicle, motor_vehicle and car apply. | The posted limit where the data gives one, else the class default below. | One-way rules apply. |
walking | Every road except motorways and trunk roads (and their slip roads), plus footways, pedestrian streets, paths, steps, tracks, cycleways and bridleways. Rules for foot apply. | 5 km/h; steps 2 km/h. | Every way both ways: a one-way street is one-way for traffic, not for a pedestrian. |
cycling | Roads and paths, but no motorway, trunk or steps. Rules for bicycle and vehicle apply. | 18 km/h on a cycleway; 15–16 on streets; 10–12 on service roads, paths and tracks; 5 where a bicycle is pushed (footways, pedestrian streets). | One-way rules apply. |
rail | Railway track, not roads. Rules for train and rail apply. | The posted limit where given, else a line speed: 60 km/h for standard and narrow gauge, 45 subway, 40 light rail and monorail, 25 tram, 10 funicular. | As the track allows. |
live | The driving network. | Driving's, with the roads an operator's traffic feed names at their live speed. | As driving. |
rail is the track network, useful for how far and how long a train takes along the line. It knows nothing of timetables; for when the next train leaves and how to get there by public transport, seejourney planning.
The driving profile's classes, and the speed it assumes on each where no limit is posted:
| Class | Default km/h | Class | Default km/h |
|---|---|---|---|
motorway | 100 | residential | 30 |
trunk | 80 | unclassified | 30 |
primary | 60 | unknown | 30 |
secondary | 50 | service | 20 |
tertiary | 40 | alley | 15 |
living_street | 10 |
The same trip on foot:
curl -G "https://api.oslew.com/v1/route" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'from=19.4406,-99.2047' \
--data-urlencode 'to=19.4326,-99.1332' \
--data-urlencode 'profile=walking' \
--data-urlencode 'geometry=false'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.route(
"19.4406,-99.2047",
"19.4326,-99.1332",
geometry=False,
profile="walking",
)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.route("19.4406,-99.2047", "19.4326,-99.1332", { geometry: false, profile: "walking" });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 298
ratelimit-reset: 1
{
"from": [
19.4406,
-99.2047
],
"to": [
19.4326,
-99.1332
],
"snapped_from": {
"from": 434020,
"to": 434026,
"frac": 1,
"lat": 19.44050138408404,
"lon": -99.20451818453606,
"distance_m": 21.99305218267701,
"time_ds": 324,
"len_m": 18,
"two_way": true
},
"snapped_to": {
"from": 387407,
"to": 387421,
"frac": 0.45641447518550365,
"lat": 19.432124810825027,
"lon": -99.13328961848858,
"distance_m": 53.66787209985155,
"time_ds": 940,
"len_m": 131,
"two_way": true
},
"found": true,
"distance_m": 7979,
"duration_s": 5761.4,
"nodes": 142,
"settled": 1002,
"geometry": [],
"engine": "base/hierarchy",
"provenance": {
"name": "overture-transportation",
"release": "2026-08-19.0",
"license": "ODbL-1.0"
},
"took_us": 3052
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
7,979 m in 5,761.4 s — 96 minutes at 5 km/h. It is 1.3 km shorter than the drive because a pedestrian can take footways and walk against one-way streets, and both ends snapped somewhere else: the walking network has edges the driving one does not, so the nearest one to Museo Soumaya is 22 m away rather than 40.
Access rules with a condition attached — a time window, a vehicle size, a purpose — are not applied. A road closed to cars at night is routed as open all day, and a restriction for lorries does not close it to a car. Unconditional rules, including one-way streets, are applied.
Use the profile names exactly
The profile is one of driving, walking, cycling, rail orlive, in lowercase. Anything else is a 400:
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"error": "unknown profile `base`; driving, walking, cycling or rail"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Where a profile's network is not loaded at all, the answer is a 400 naming the profile and listing the ones that are.
Where a route starts: snapping
The two points you send are rarely on a road. Each is moved to the nearest point on a road in the profile's network — a point part-way along an edge, not the nearest junction, because the nearest junction to a point mid-block can be half a block away. The route starts there and pays only for the part of that edge it travels, in whichever direction the edge allows. The answer says where each end landed:
Field of snapped_from, snapped_to | Is |
|---|---|
lat, lon | The snapped position, on the road. |
distance_m | How far the point you sent was from it. Worth checking: a point 400 m from the nearest road is on no road at all, and the route starts somewhere the user may not expect. |
from, to | The edge's two junctions, as node ids of this release's graph. Two answers on the same edge share them; they are not stable across releases. |
frac | Where along the edge, 0 at from and 1 at to. |
len_m, time_ds | The whole edge's length in metres and travel time in tenths of a second. |
two_way | Whether the edge can also be travelled from to to from. |
The search looks within about 600 m first and widens to about 9 km. Beyond that, the route is refused with400, no road within 9 km of from (or of to).
Snapping looks only at distance. It does not know which side of a divided road you are on or which way you are heading, so a point beside a dual carriageway can snap to the one going the other way — two_way: false— and the route then goes the long way round to turn. When that matters, move the point onto the side you mean. To see where a point will snap before routing from it, and what road it lands on, seesnapping to roads.
found: false is an answer; a 400 is not
Two different things can go wrong, and they come back differently:
- The request cannot be answered — a point that does not parse, an unknown profile, a point more than 9 km from any road, a network that is not loaded. That is a
400with anerrorsentence. Retrying will not help; change the request. - Both ends are on the network and nothing connects them — an island with no bridge in the data, a gated estate the profile may not enter, a one-way trap. That is a
200withfound: false,distance_mandduration_snull,nodes0 and an emptygeometry. The snapped ends are still there, so you can show the user where the route would have started.
from oslew import Client, BadRequest
client = Client(base_url="https://api.oslew.com")
try:
route = client.route("19.4406,-99.2047", "19.4326,-99.1332", profile="walking", geometry=False)
except BadRequest as e:
... # the request is wrong: say what e.message says
else:
if not route["found"]:
... # both ends are on the network, and nothing joins them
else:
minutes = route["duration_s"] / 60import { Client, BadRequest } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" });
try {
const route = await client.route("19.4406,-99.2047", "19.4326,-99.1332", { profile: "walking", geometry: false });
if (!route.found) {
// both ends are on the network, and nothing joins them
} else {
const minutes = route.duration_s / 60;
}
} catch (e) {
if (e instanceof BadRequest) {
// the request is wrong: say what e.message says
} else throw e;
}Distance and duration
distance_m is whole metres along the route, including the part-edges at each end.duration_s is seconds, to a tenth: the sum of every edge's travel time, where an edge's time is its length at the profile's speed on it — the posted limit for driving and rail where the data gives one, the class speed otherwise, and the class speed always on foot and by bicycle.
That makes it a free-flow time. Nothing is added for junctions, traffic signals, turns or congestion, so in a city at rush hour a driving time is a lower bound on what a driver will see. Where an operator applies a live traffic feed, profile=live routes on it instead; see live traffic.
nodes is the number of points in the path, counted whether or not you asked for the geometry.settled is how many junctions the search examined to find it — a measure of the engine's work, useful for comparing engines and not much else.
The path
geometry is a list of [lat, lon] pairs: the snapped start, every junction the route passes through, and the snapped end. A short one, shortened further for this page:
curl -G "https://api.oslew.com/v1/route" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'from=19.4326,-99.1332' \
--data-urlencode 'to=19.4352,-99.1412'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.route("19.4326,-99.1332", "19.4352,-99.1412")import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.route("19.4326,-99.1332", "19.4352,-99.1412");HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 297
ratelimit-reset: 1
{
"from": [
19.4326,
-99.1332
],
"to": [
19.4352,
-99.1412
],
"snapped_from": {
"from": 355496,
"to": 355490,
"frac": 0.16199866758190418,
"lat": 19.43200133133587,
"lon": -99.13329035902773,
"distance_m": 67.23995201279342,
"time_ds": 110,
"len_m": 92,
"two_way": false
},
"snapped_to": {
"from": 289909,
"to": 289914,
"frac": 0.6128848307339685,
"lat": 19.435137788683768,
"lon": -99.14071924890425,
"distance_m": 50.883507740291044,
"time_ds": 35,
"len_m": 49,
"two_way": false
},
"found": true,
"distance_m": 1699,
"duration_s": 208.9,
"nodes": 28,
"settled": 78,
"geometry": [
[
19.43200133133587,
-99.13329035902773
],
[
19.431903616212214,
-99.1325623738953
],
[
19.431911572708522,
-99.13244027479968
],
[
19.43171223480434,
-99.13232577540224
],
[
19.431627961164846,
-99.13232788637784
],
[
19.43085290660703,
-99.13234781399032
]
],
"engine": "base/hierarchy",
"provenance": {
"name": "overture-transportation",
"release": "2026-08-19.0",
"license": "ODbL-1.0"
},
"took_us": 679
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call. Shortened for the page: geometry shows 6 of 28.
The points are the junctions, not the shape of the road between them. A road that curves between two junctions is drawn as a straight line from one to the next — fine for showing a route at city zoom, not a centreline to measure along. For the length, use distance_m, which is measured along the road's real shape.
Drawing it
GeoJSON and every map library that reads it want [lon, lat], the other way round. Swap once, where the answer enters your code:
route = client.route("19.4326,-99.1332", "19.4352,-99.1412")
if route["found"]:
feature = {
"type": "Feature",
"properties": {"distance_m": route["distance_m"], "duration_s": route["duration_s"]},
# The service's geometry is [lat, lon]; GeoJSON is [lon, lat].
"geometry": {
"type": "LineString",
"coordinates": [[lon, lat] for lat, lon in route["geometry"]],
},
}const route = await client.route("19.4326,-99.1332", "19.4352,-99.1412");
if (route.found) {
const feature = {
type: "Feature",
properties: { distance_m: route.distance_m, duration_s: route.duration_s },
// The service's geometry is [lat, lon]; GeoJSON is [lon, lat].
geometry: {
type: "LineString",
coordinates: route.geometry.map(([lat, lon]) => [lon, lat]),
},
};
}Build the feature on your server and send that to the browser, not the key: the service sends no CORS headers, and a key in a web page is a key anyone can use. See authentication.
engine: what answered
| Value | Means |
|---|---|
base/hierarchy | The release's speeds, searched through a precomputed contraction hierarchy. Every profile, and live when no traffic feed is applied. |
live/dijkstra | Live speeds from a traffic feed applied moments ago, searched by plain Dijkstra while the hierarchy for the new speeds is built. |
live/hierarchy | Live speeds, with their hierarchy built. |
The two live values find the same fastest time; the second finds it with far less work. Asking for live where no feed is applied is not an error — the answer says base/hierarchy, and that field is how you tell.
The data and its licence
Routes are built from Overture's transportation theme, and provenance says so on every answer, with the release. That data is ODbL-1.0 — share-alike — which matters if you store routes or times in a database you distribute. See data and licensing. How complete the network is, and how many roads carry a posted limit, depends on the data loaded for the area.
Endpoints
/v1/routeroutingThe fastest road route between two points, each snapped to the nearest point on a road.