oslew docs
Console
Menu

RoutingroutingoperationId route

GET/v1/route

The fastest road route between two points, each snapped to the nearest point on a road.

Send Authorization: Bearer sk_live_…. The key's plan must include therouting product; which plans do.

Explained in Products and plans, Errors, Routes and profiles, Live traffic, Operator feeds, A store locator and Delivery planning.

Example

Driving from Museo Soumaya to the Zócalo.

curl
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'
Python
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)
TypeScript
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 });
Response
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.

Query

NameTypeDescription
from
queryrequired
string
lat,lon.
to
queryrequired
string
lat,lon.
geometry
query
boolean
default true
Return the path as (lat, lon) per node.
profile
query
string
driving | walking | cycling | rail | live
default driving
The mode; each has its own network, speeds and access rules. live is driving on the traffic feed's weights when one is applied, and the release's weights when none is.
traffic
query
string
live
Use the traffic feed's weights when one is applied (driving only); the same as profile=live.

Responses

200 — The route, or found: false.

  • distance_minteger | nullrequired
  • duration_snumber | nullrequired
    At the posted limit where given, else the class default speed; no traffic.
  • enginestringrequired
  • foundbooleanrequired
  • fromnumber[]required
  • geometrynumber[][]required
    (lat, lon): the snapped origin, every node, the snapped destination.
  • nodesintegerrequired
  • provenanceSourcerequired
    • licensestringrequired
    • namestringrequired
    • releasestringrequired
  • settledintegerrequired
  • snapped_fromEdgeSnaprequired
    • distance_mnumberrequired
      From the query point to the snapped position.
    • fracnumberrequired
      Position along the edge, 0 at from, 1 at to.
    • fromintegerrequired
    • latnumberrequired
    • len_mintegerrequired
    • lonnumberrequired
    • time_dsintegerrequired
    • tointegerrequired
    • two_waybooleanrequired
  • snapped_toEdgeSnaprequired
    • distance_mnumberrequired
      From the query point to the snapped position.
    • fracnumberrequired
      Position along the edge, 0 at from, 1 at to.
    • fromintegerrequired
    • latnumberrequired
    • len_mintegerrequired
    • lonnumberrequired
    • time_dsintegerrequired
    • tointegerrequired
    • two_waybooleanrequired
  • tonumber[]required
  • took_usintegerrequired

With RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset(and their X-RateLimit-* aliases); see rate limits.

Refusals

Every refusal is a JSON object with an error string, except where noted.

400Bad request, or no road within 9 km.
401No key, or one that is unknown, revoked or suspended.
403The key's plan does not include this route's product, or the request is larger than the plan allows. The body names the plan that does.
429This product's bucket is empty: the key is going faster than its plan's sustained rate. Wait Retry-After seconds; nothing is used up. Carries Retry-After.
503The pod cannot reach the control plane and its entitlements are too old to trust. Retry.

A malformed query string or JSON body is refused by the framework before this route runs, in plain text rather than JSON; see errors.

More examples

The same trip on foot
curl
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'
Python
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",
)
TypeScript
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" });
Response
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.

A short route with its geometry
curl
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'
Python
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")
TypeScript
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");
Response
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.

A key whose plan does not include the product
curl
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'
Python
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")
TypeScript
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");
Response
HTTP/1.1 403 Forbidden
content-type: application/json

{
  "error": "the free plan does not include routing; Routing ($299/mo) does"
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

An unknown profile
curl
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=base'
Python
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", profile="base")
TypeScript
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", { profile: "base" });
Response
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.

The same route on live weights
curl
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 'traffic=live' \
  --data-urlencode 'geometry=false'
Python
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,
    traffic="live",
)
TypeScript
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, traffic: "live" });
Response
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": 65350,
  "geometry": [],
  "engine": "live/dijkstra",
  "provenance": {
    "name": "overture-transportation",
    "release": "2026-08-19.0",
    "license": "ODbL-1.0"
  },
  "took_us": 7120
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Rendered from the OpenAPI document at commit b8f4bde-dirty; the same document is served at/v1/openapi.json and generates both clients.