Open Source Routing Machine for OpenStreetMap API Lib and App



Open Source Routing Machine for OpenStreetMap API Lib and App.

Open Source Routing Machine


  • nimble install osrm


import osrm, asyncdispatch, json

let ## Demo Data.
  foo: OSRMCoords = (lat: 13.388860.float32, lon: 52.517037.float32)
  bar: OSRMCoords = (lat: 13.397634.float32, lon: 52.529407.float32)

## Sync client.
let osrmc = OSRM(timeout: 99.byte, proxy: nil)
echo osrmc.nearest(number=42.byte, profile=OSRMBike, coordinates= @[foo]).pretty
echo osrmc.route(profile=OSRMBike, coordinates= @[foo, bar]).pretty
echo osrmc.table(profile=OSRMBike, coordinates= @[foo, bar], sources= @[0.byte, 1.byte], destinations= @[0.byte, 1.byte]).pretty
echo osrmc.match(profile=OSRMCar, coordinates= @[foo, bar]).pretty
echo osrmc.trip(profile=OSRMCar, coordinates= @[foo, bar]).pretty

## Async client.
proc async_osrm() {.async.} =
    async_osrmc = AsyncOSRM(timeout: 99.byte)
    async_response = await async_osrmc.nearest(number=42.byte, profile=OSRMBike, coordinates= @[foo])
  echo async_response.pretty

wait_for async_osrm()

# Check the Docs for more API Calls...

Command Line App

Finds the best fastest Route between 2 Coordinates (lat,lon) in supplied order using the Open Source Routing Machine for OpenStreetMap API online services.

  • For Uglyfied JSON use --ugly (does not reduce bandwith usage).
  • If you dont have any Hints for the Query just use an empty string.
  • This requires at least basic skills with JSON and OpenStreeMap.
  • The App supports English and Spanish.


./osrm --color --lower --alternatives --steps --straight --overview --hints --timeout=9 --profile=bike --format=geojson --from_lat=42.666 --from_lon=10.55 --to_lat=15.42 --to_lon=12.75 "hint,hint,hint"

Uso (Spanish):

./osrm --color --minusculas --alternativas --pasos --derecho --resumen --sugerencias --timeout=9 --perfil=bici --formato=geojson --desde_lat=42.666 --desde_lon=10.55 --hasta_lat=15.42 --hasta_lon=12.75 "hint,hint,hint"


  • Modern C++ Routing engine and JSON API for shortest paths in road networks.
  • Handles continental-sized network queries within miliseconds.
  • Supports Car, Bicycle, Walk modes with easily customized profiles.
  • No Login, no auth, no payments, no credit card, no api key, just works.
  • Powered by OSRM, OpenStreetMap and Nim lang.
  • Check the OpenStreetMap Wiki, the Lib is a 1:1 copy of the official Docs.
  • This Library uses API Version 1.0 from Year 2018.
  • Each proc links to the official OSRM API docs.
  • All procs should return an JSON Object JsonNode type.
  • The order of the procs follows the order on the OSRM Wiki.
  • The naming of the procs follows the naming on the OSRM Wiki.
  • The errors on the procs follows the errors on the OSRM Wiki.
  • API Calls use HTTP GET.
  • Coordinates are float32.
  • API Calls are Anonymous and use a blank User-Agent.
  • API Calls use the DoNotTrack HTTP Header.
  • The timeout argument is on Seconds.
  • For Proxy support define a proxy of Proxy type.
  • No OS-specific code, so it should work on Linux, Windows and Mac. Not JS.
  • Run the module itself for an Example.
  • Run nim doc osrm.nim for more Documentation.


  • All OSRM API is supported.


Click to see FAQ
  • Para que sirve ?

Para hacer Apps del estilo "Como llego", para hacer Open Data, Data Science, cosas de OpenStreetMap, GeoCosos.

  • Yo solo hablo Espanol ?

La aplicacion de linea de comandos soporta Espanol.

  • This works without SSL ?.


  • This works with SSL ?.


  • This works with Asynchronous code ?.


  • This works with Synchronous code ?.


  • This requires API Key or Login ?.


  • This requires Credit Card or Payments ?.


  • Can I use the OpenStreetMap data ?.

Yes. You MUST give Credit to OpenStreetMap Contributors!.

  • How to Uglify the output?


  • How to Lowercase the output?


  • How to enable Alternatives?


  • How to enable Steps?


  • How to enable Continue Straight ?


  • How to enable Overviews ?


  • How to enable Hints ?


  • How to set a Timeout ?


  • How to set the output Format ?


  • How to set the "From" Coordinates ?

--from_lat=42.666 --from_lon=10.55

  • How to set the "To" Coordinates ?

--to_lat=15.42 --to_lon=12.75

  • How to use colors ?


  • How to set the Profile ?

--profile=bike, --profile=car, etc

  • How to see the Help ?



  • None.
Need help? Read Nimble
Available versions:
License: MIT

Project website Hosted docs