All projects
Personal project · 2022

osrm-node-api

A high-performance NodeJS server implementation for the Open Source Routing Machine (OSRM) backend.

NodeJSTypeScriptGeographic Services
Source on GitHubLast updated November 2026

What it does

osrm-node-api is a routing service for OpenStreetMap road data. Give it points on a map, and it answers four kinds of questions, using OSRM, a fast open-source routing engine:

Route

/route

The fastest way through two or more points, with turn-by-turn steps if you want them.

Table

/table

Travel times from every start (A–C) to every destination (1–3), in one call.

Nearest

/nearest

The closest points on the road to a coordinate, nearest first.

Match

/match

Snaps a noisy GPS trace onto the roads it most likely followed.

What it adds to OSRM

OSRM ships its own server, osrm-routed, which works well on a laptop. Running routing as a service needs more around it, and that layer is what this project is.

osrm-node-api
  • OSRM engine
    the routing itself
  • Several processes
    Parallel workers behind one port
  • Metrics
    Latency and errors, for Prometheus
  • Health checks
    /liveness computes a real route
  • Request logs
    One line per request, with a trace ID
  • Input checks
    Unknown parameters get a 400
  • One Docker image
    OSRM v6.0.0 built from source

How a request moves

Client
GET or POST /route /table /nearest /match
Docker container
Worker process × N
Forked by Node cluster; each creates its own OSRM instance
  1. 1Helmet headers, JSON body, timing log
  2. 2Check parameters against the service’s whitelist
  3. 3Call the OSRM Node binding on the libuv thread pool
Primary process
Forks the workers; serves /metrics on :9090, summed across workers
Logs
info and error files, rotated daily, kept 7 days
.osrm graph files
Prepared from OpenStreetMap; CH or MLD
🎵 My AI-generated music [AI in 2026] is playing. Toggle it on/off in the header.