RoutingroutingoperationId optimize
GET/v1/optimize
The fastest order to visit 2 to 500 points: a duration matrix, then nearest-neighbour, 2-opt and Or-opt (exact up to 8 points), with the legs routed.
Send Authorization: Bearer sk_live_…. The key's plan must include therouting product; which plans do.
Explained in Visit order and Delivery planning.
Example
The fastest round trip through four points.
curl -G "https://api.oslew.com/v1/optimize" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'points=19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620' \
--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.optimize(
"19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620",
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.optimize("19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620", { geometry: false });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 294
ratelimit-reset: 1
{
"order": [
0,
2,
1,
3,
0
],
"waypoints": [
[
19.4406,
-99.2047
],
[
19.4352,
-99.1412
],
[
19.4326,
-99.1332
],
[
19.35,
-99.162
],
[
19.4406,
-99.2047
]
],
"duration_s": 2173,
"legs_s": [
561,
170,
651,
791
],
"nearest_neighbour_s": 2173,
"distance_m": 34016,
"geometry": [],
"engine": "base/hierarchy",
"provenance": {
"name": "overture-transportation",
"release": "2026-08-19.0",
"license": "ODbL-1.0"
},
"took_us": 5137
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Query
| Name | Type | Description |
|---|---|---|
pointsqueryrequired | string | lat,lon;lat,lon;… |
roundtripquery | boolean default true | |
sourcequery | string first | any default first | |
destinationquery | string last | any default any | |
profilequery | string driving | walking | cycling | rail default driving | The mode; each has its own network, speeds and access rules. |
trafficquery | string live | Use the traffic feed's weights when one is applied (driving only). |
geometryquery | boolean default true |
Responses
200 — The order.
distance_mintegerrequiredduration_snumberrequiredenginestringrequiredgeometrynumber[][]requiredlegs_snumber[]requirednearest_neighbour_snumberrequiredThe unimproved order's duration.orderinteger[]requiredprovenanceSourcerequiredlicensestringrequirednamestringrequiredreleasestringrequired
took_usintegerrequiredwaypointsnumber[][]required
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.
| 400 | Bad request, or no order visits every point. |
| 401 | No key, or one that is unknown, revoked or suspended. |
| 403 | The 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. |
| 429 | This 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. |
| 503 | The 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
Start at the first point and end anywhere
curl -G "https://api.oslew.com/v1/optimize" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'points=19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620' \
--data-urlencode 'roundtrip=false' \
--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.optimize(
"19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620",
roundtrip=False,
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.optimize("19.4406,-99.2047;19.4326,-99.1332;19.4352,-99.1412;19.3500,-99.1620", { roundtrip: false, geometry: false });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 293
ratelimit-reset: 1
{
"order": [
0,
2,
1,
3
],
"waypoints": [
[
19.4406,
-99.2047
],
[
19.4352,
-99.1412
],
[
19.4326,
-99.1332
],
[
19.35,
-99.162
]
],
"duration_s": 1382,
"legs_s": [
561,
170,
651
],
"nearest_neighbour_s": 1382,
"distance_m": 20755,
"geometry": [],
"engine": "base/hierarchy",
"provenance": {
"name": "overture-transportation",
"release": "2026-08-19.0",
"license": "ODbL-1.0"
},
"took_us": 4153
}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.