Optimize delivery routes
optimize_routesPlan routes for one or more vehicles from one depot and return, per vehicle, the stop order with arrival times and load so far, plus stops that could not be served, totals, Google Maps links and warnings. Uses real road driving times. Solves take 10-60 s (more when many addresses must be looked up). Pass either example or the fields below. If the result has status 'running', call get_route_result with its job_id. Minimal example: {"depot": {"address": "1600 Pennsylvania Ave NW, Washington, DC 20500"}, "stops": [{"id": "Ana", "address": "..."}, {"id": "Bob", "lat": 38.9, "lon": -77.03, "window_open": "09:00", "window_close": "12:00", "service_minutes": 10}], "vehicles": 2}. Omitted: capacity = unlimited, no time windows, 1 vehicle, stops are dropped only when they cannot be served at all. Call get_route_example for complete, realistic inputs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depot | No | Where every vehicle starts and ends. Needs an address or lat+lon. | |
| stops | No | The places to visit (not the depot). Each needs an address or lat+lon. | |
| country | No | Which geocoder reads the addresses: US (US Census, then OpenStreetMap) or OTHER (OpenStreetMap). Default US. | |
| example | No | Solve this built-in example instead of passing the fields below. | |
| vehicles | No | Either a number of identical vehicles (unlimited capacity), or one object per vehicle. | |
| parameters | No | Optional engine settings: SearchParametersTimeLimit (seconds, default 30, max 60), NoImprovementSeconds (20), RouteTimeLimit (minutes, default 1440), DroppedOrderCost (100000 = serve every stop that can be served), MinuteCost (1), LatePenaltyPerMinute (0 = windows are hard), MaxWaitMinutes (1440), MinimumDriveTime (5). | |
| wait_seconds | No | How long to wait for the solve inside this call (default 25). | |
| previous_routes | No | Re-optimize from existing routes: one list of stop ids (or 1-based stop numbers) per vehicle, in visiting order. The solver starts from these and improves them; new stops are fitted in. |