OSRM API Documentation & Explorer

Explore and test all available OSRM routing endpoints

← Back to Route Planner

API Configuration

Your OSRM API base URL
X-API-Key header value

Route Service

GET
Finds the fastest route between coordinates. Returns a route with geometry, distance, and duration.

URL Pattern

/route/v1/{profile}/{coordinates}?{options}

Path Parameters

profile
Mode of transportation: driving, walking, or cycling
coordinates
Semicolon-separated list of {longitude},{latitude} pairs (min 2)

Query Parameters (Optional)

steps
Include turn-by-turn instructions (true/false, default: false)
geometries
Route geometry format: polyline, polyline6, or geojson (default: polyline)
overview
Route geometry detail: full, simplified, or false (default: simplified)
alternatives
Number of alternative routes (0-3, default: 0)
Example Request
GET /route/v1/driving/-122.4194,37.7749;-122.4783,37.8199?overview=full&steps=true

Try It Out

Use example

Table Service (Distance Matrix)

GET
Computes duration and distance matrices for multiple source and destination coordinates. Returns an NxM matrix showing travel times and distances between all location pairs. Essential for analyzing accessibility, service coverage areas, and location optimization.

URL Pattern

/table/v1/{profile}/{coordinates}?{options}

Path Parameters

profile
Mode of transportation: driving, walking, or cycling
coordinates
Semicolon-separated list of {longitude},{latitude} pairs (minimum 2 locations required)

Query Parameters (Optional)

sources
Indices of source coordinates (0-indexed, semicolon-separated). Default: all. Example: sources=0;1
destinations
Indices of destination coordinates (0-indexed, semicolon-separated). Default: all. Example: destinations=2;3
annotations
Data to include in response: duration, distance, or both (comma-separated). Default: duration. Example: annotations=duration,distance
Example Request (Full Matrix)
GET /table/v1/driving/-122.4194,37.7749;-122.4783,37.8199;-122.2711,37.8044?annotations=duration,distance
Example Response
{ "code": "Ok", "durations": [ [0, 845.3, 1234.5], [856.2, 0, 987.6], [1245.8, 976.3, 0] ], "distances": [ [0, 12345.6, 23456.7], [12456.8, 0, 15678.9], [23567.9, 15789.1, 0] ], "sources": [...], "destinations": [...] }
💡 Use Cases:
  • Finding the nearest warehouse/store to multiple customers
  • Analyzing service coverage areas and travel time zones
  • Route planning data for TSP/VRP algorithms
  • Location optimization for facilities and distribution centers

Try It Out

Use example

Match Service (Map Matching)

GET
Snaps GPS traces to the road network. Useful for matching raw GPS data to actual road segments.

URL Pattern

/match/v1/{profile}/{coordinates}?{options}

Path Parameters

profile
Mode of transportation: driving, walking, or cycling
coordinates
Semicolon-separated list of {longitude},{latitude} pairs (min 2)

Query Parameters (Optional)

steps
Include turn-by-turn instructions (true/false, default: false)
geometries
Route geometry format: polyline, polyline6, or geojson (default: polyline)
overview
Route geometry detail: full, simplified, or false (default: simplified)
Example Request
GET /match/v1/driving/-122.4194,37.7749;-122.4183,37.7755;-122.4180,37.7760?overview=full

Try It Out

Use example

Trip Service (Traveling Salesman Problem - TSP)

GET
Solves the Traveling Salesman Problem (TSP) to find the shortest route that visits all locations. The service automatically optimizes the visit order to minimize total distance/duration. Perfect for delivery routes, tour planning, and multi-stop itineraries.

URL Pattern

/trip/v1/{profile}/{coordinates}?{options}

Path Parameters

profile
Mode of transportation: driving, walking, or cycling
coordinates
Semicolon-separated list of {longitude},{latitude} pairs (minimum 2 locations required)

Query Parameters (Optional)

roundtrip
Return to starting point (true/false, default: true). Set to false for one-way trips.
source
Starting coordinate: first (default), last, or any (let algorithm choose optimal start)
destination
Ending coordinate: last (default), first, or any (let algorithm choose optimal end)
steps
Include turn-by-turn instructions (true/false, default: false)
geometries
Route geometry format: polyline, polyline6, or geojson (default: polyline)
overview
Route geometry detail: full, simplified, or false (default: simplified)
Example Request (Roundtrip)
GET /trip/v1/driving/-122.4194,37.7749;-122.4783,37.8199;-122.2711,37.8044?roundtrip=true&source=first&geometries=geojson
Example Response
{ "code": "Ok", "trips": [{ "distance": 45678.9, "duration": 3456.7, "geometry": {...}, "legs": [...] }], "waypoints": [ { "waypoint_index": 0, "trips_index": 0, "hint": "...", "distance": 0, "name": "Market Street", "location": [-122.4194, 37.7749] }, ... ] }
💡 Use Case: The Trip API is ideal for route optimization scenarios where you need to visit multiple locations efficiently. The algorithm will reorder your waypoints to minimize total travel time or distance, making it perfect for delivery routes, sales visits, or sightseeing tours.

Try It Out

Use example

Nearest Service

GET
Returns the nearest road segments for a given coordinate. Useful for finding the closest point on the road network.

URL Pattern

/nearest/v1/{profile}/{coordinate}?{options}

Path Parameters

profile
Mode of transportation: driving, walking, or cycling
coordinate
Single {longitude},{latitude} coordinate

Query Parameters (Optional)

number
Number of nearest segments to return (default: 1, max: 100)
Example Request
GET /nearest/v1/driving/-122.4194,37.7749?number=3

Try It Out

Use example