Skip to content

Latest commit

 

History

History
122 lines (78 loc) · 2.3 KB

File metadata and controls

122 lines (78 loc) · 2.3 KB

OSRM API Request Examples

This file contains ready-to-use curl commands and raw request URLs for the gateway.

Base URL

BASE_URL="http://localhost"

1. Health Check

curl

curl -s "$BASE_URL/"

request URL

GET http://localhost/

2. Route API

2.1 Car Route

curl

curl -s "$BASE_URL/car/route/v1/driving/7.421,43.729;7.424,43.733?overview=false"

request URL

GET http://localhost/car/route/v1/driving/7.421,43.729;7.424,43.733?overview=false

2.2 Walk Route

curl

curl -s "$BASE_URL/walk/route/v1/walking/7.421,43.729;7.424,43.733?overview=false"

request URL

GET http://localhost/walk/route/v1/walking/7.421,43.729;7.424,43.733?overview=false

2.4 Car Route with Geometry (GeoJSON)

curl

curl -s "$BASE_URL/car/route/v1/driving/13.388599,52.517037;13.397634,52.529407?geometries=geojson"

request URL

GET http://localhost/car/route/v1/driving/13.388599,52.517037;13.397634,52.529407?geometries=geojson

3. Matrix (Table) API

3.1 Car Matrix (Duration + Distance)

curl

curl -s "$BASE_URL/car/table/v1/driving/7.421,43.729;7.424,43.733;7.418,43.732?annotations=duration,distance"

request URL

GET http://localhost/car/table/v1/driving/7.421,43.729;7.424,43.733;7.418,43.732?annotations=duration,distance

3.2 Walk Matrix (Duration + Distance)

curl

curl -s "$BASE_URL/walk/table/v1/walking/7.421,43.729;7.424,43.733;7.418,43.732?annotations=duration,distance"

request URL

GET http://localhost/walk/table/v1/walking/7.421,43.729;7.424,43.733;7.418,43.732?annotations=duration,distance

4. Pretty JSON Output (Optional)

Use jq for formatted output.

curl -s "$BASE_URL/car/route/v1/driving/7.421,43.729;7.424,43.733?overview=false" | jq .
curl -s "$BASE_URL/car/table/v1/driving/7.421,43.729;7.424,43.733;7.418,43.732?annotations=duration,distance" | jq .

5. Direct Backend Ports (Optional)

You can bypass gateway and call direct containers.

car backend

curl -s "http://localhost:5000/route/v1/driving/7.421,43.729;7.424,43.733?overview=false"

walk backend

curl -s "http://localhost:5002/route/v1/walking/7.421,43.729;7.424,43.733?overview=false"