Overview
Trip API solves the traveling salesman problem (TSP): given several stops, it returns an approximately optimal visiting order. Great for delivery route previews and multi-stop visit planning. Powered by the OSRM Trip service.Need richer constraints (multiple vehicles, time windows, capacity)? Use Fleet Optimization instead.
Endpoint
Request Parameters
Service options
General options
These options apply to all routing services. Options that take one value per coordinate use the array-like encoding{option}={element};{element}[;...] — the number of elements must match the number of coordinates (except generate_hints and exclude). Pass an empty element to use the default for that coordinate, e.g. bearings=;90,20;.
Fixing start and end points
Usesource and destination to pin where the trip begins and ends: source=first starts at the first input coordinate, destination=last ends at the last one. With any, any coordinate may fill that role — though a round-trip with source=any&destination=any still starts at the first input coordinate by default.
Not all combinations of roundtrip, source, and destination are supported:
TSP is NP-hard, so the result is approximately optimal (brute force guarantees the optimum below 10 points). All input coordinates must be connected for the trip to be solvable.
Quickstart
Response
response-example.json
Response fields
Errors
See Errors for the full list.
Related
- Fleet Optimization — multi-vehicle VRP
- Directions API
