Skip to content
Optimization API

Optimization API

Finds the best order of stops (traveling salesman) or plans tours for several vehicles with capacities and time windows.

Base URL: https://api.mapx.at · Rate-limit zone: heavy (30/min) · Guide: Navigation

Optimized order

GET /v1/optimized-trips/{profile}/{coordinates}

2 to 25 coordinates. Exact up to 12 points, above that nearest neighbour with 2-opt and Or-opt over the duration matrix. Response like Directions: trips[] with one route, waypoints[] in input order with waypoint_index (position in the trip) and trips_index.

More

Expensive: zone heavy.

Parameters

NameInTypeRequiredDefaultDescription
profilepathstringyes–driving, driving-traffic (with current traffic and closures), driving-truck (trucks over 3.5 t; vehicle size via weight/height/width/length/truck_type), cycling, cycling-mtb or walking (mapbox/ prefix allowed)
coordinatespathstringyes–lon,lat;lon,lat;…
sourcequerystring–any (default) or first (point 0 is the start)
destinationquerystring–any (default) or last (last point is the end)
roundtripquerystring–true (default) returns to the start, or false; true with destination=last needs source=first
stepsquerystring–true for turn-by-turn steps
geometriesquerystring–geojson|polyline|polyline6
overviewquerystring–simplified (default) | full | false
languagequerystring–de (default) or en

Example

curl -s -H "Authorization: Bearer YOUR_TOKEN" "https://api.mapx.at/v1/optimized-trips/driving/16.3725,48.2085;15.6256,48.2049;14.2858,48.3069?roundtrip=true" | jq

Example response

{
  "code": "Ok",
  "trips": [],
  "waypoints": []
}

Errors (details: error catalog)

StatusMeaning
400A parameter is missing or invalid
401Token missing or invalid (missing-token, invalid-token, token-expired)
403Token not allowed here (origin-not-allowed, origin-missing, pk-not-allowed, app-not-allowed, token-blocked, ip-not-allowed)
422Valid request that cannot be answered (for example no route)
429Rate limit exceeded, wait Retry-After seconds
502Upstream service unavailable

Tour planning (simplified Optimization v2)

POST /v1/optimization

Vehicles with start/end/capacity/time window, services (one location) and shipments (pickup before delivery, same vehicle) with duration, time windows and amounts. Heuristic: regret insertion, local search, ruin and recreate until options.time_limit_ms. At most 10 vehicles, 50 jobs, 60 distinct locations, 256 KB.

More

Times in seconds. Expensive: zone heavy.

Request body (JSON)

NameTypeDescription
profilestringdriving (default), cycling, cycling-mtb or walking

Example

curl -s -X POST "https://api.mapx.at/v1/optimization" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"vehicles":[{"id":1,"start":[16.3725,48.2083],"end":[16.3725,48.2083]}],"services":[{"id":1,"location":[15.6256,48.2049],"service":300},{"id":2,"location":[14.2858,48.3069],"service":300}]}' | jq

Example response

{
  "summary": {
    "cost": 9000,
    "unassigned": 0
  },
  "routes": [],
  "unassigned": []
}

Errors (details: error catalog)

StatusMeaning
400A parameter is missing or invalid
401Token missing or invalid (missing-token, invalid-token, token-expired)
403Token not allowed here (origin-not-allowed, origin-missing, pk-not-allowed, app-not-allowed, token-blocked, ip-not-allowed)
405Method not allowed
429Rate limit exceeded, wait Retry-After seconds
502Upstream service unavailable

Playground

Playground
curl
The response appears here.