OSRM API (Open Source Routing Machine)
Dec 29,2025

GISBox is a one-stop 3D GIS data editing, conversion and publishing platform that supports editing in multiple GIS formats such as OSGB/GEOTIFF/RVT, converting to 3DTiles/Terrain and publishing.

Introduction

OSRM API (Open Source Routing Machine) is a high-performance open-source routing engine based on OpenStreetMap data, providing route calculation services through RESTful HTTP interfaces. It supports multiple travel modes such as driving, cycling, and walking, and can quickly return the shortest path results. It is widely used in navigation application development, logistics delivery planning, travel time analysis, and other scenarios. Core features include route calculation, multi-point travel time matrix generation, GPS trajectory matching, etc., utilizing the Contraction Hierarchies algorithm to achieve millisecond-level response times.

File Structure

The file structure of OSRM API (Open Source Routing Machine) primarily involves the following aspects:

  1. Core Data Files: .osrm main data file, .osrm.nodes node data, .osrm.edges edge data, .osrm.geometry geometry data, .osrm.fileIndex file index.
  2. Routing Algorithm-Related Files: .osrm.hsgr hierarchical graph structure, .osrm.ramIndex memory index, .osrm.timestamp timestamp, .osrm.tld traffic data.
  3. Auxiliary Files: .osrm.icd intersection classification data, .osrm.names road name index, .osrm.properties property data, .osrm.restrictions traffic restriction rules.

Pros

  1. High-Performance Computing: Utilizes the Contraction Hierarchies algorithm, capable of processing road networks with tens of millions of nodes. Query response times are consistently at the millisecond level, meeting real-time application requirements.
  2. Multi-Mode Support: Natively supports various transportation modes such as driving (car), cycling (bicycle), and walking (foot), each with predefined routing rules (e.g., speed limits, one-way restrictions).
  3. Open Data Ecosystem: Based on OpenStreetMap's global road data, offering broad coverage and continuous updates, allowing developers to freely use and modify the data.
  4. High Customizability: Routing logic can be flexibly adjusted via Lua configuration files, such as setting vehicle size restrictions, avoiding toll roads, or adjusting road priorities.
  5. Standardized Interfaces: Provides RESTful HTTP APIs supporting core functions like route planning and distance matrix calculation, making it easy to integrate into web or mobile applications.

Cons

  1. Lack of Official Technical Support: As an open-source project, it lacks commercial-level after-sales support, and issues must rely on community solutions.
  2. Complex Data Preprocessing: Requires preprocessing OpenStreetMap data to generate the routing graph, which is time-consuming and demands significant hardware resources.
  3. Dependence on Data Quality: Routing accuracy heavily relies on the completeness and update frequency of OpenStreetMap data, which may be incomplete in some regions.
  4. Scalability Limitations: Although it supports a plugin mechanism, advanced features (e.g., real-time traffic flow integration) require independent development, increasing maintenance costs.

Application Scenario

OSRM API (Open Source Routing Machine) is widely used in navigation application development, logistics delivery route optimization, travel time analysis, and location intelligence services. Its high-performance route calculation capabilities support real-time route planning for scenarios such as car navigation, cycling route recommendations, and walking navigation. In the logistics field, OSRM can optimize delivery routes and calculate the shortest paths between multiple points, improving transportation efficiency. Additionally, its GPS trajectory matching function is useful for vehicle monitoring and trajectory analysis, while its Traveling Salesman Problem (TSP) solving capability supports complex needs like tourism route planning. As an open-source tool, OSRM also offers developers flexible road network data customization and routing rule adjustment capabilities to meet personalized project requirements.

Example

1. Using OSRM to add navigation functionality to your OpenStreetMap.


2. OSRM HTTP requests follow a unified URL structure.

File Opening Mode

1. Using OSRM to add navigation functionality to your OpenStreetMap.

Related GIS Services

Web Coverage Service (WCS)

Web Feature Service(WFS)

Web Map Tile Service (WMTS)

Tile Map Service (TMS)

References

  1. https://project-osrm.org/docs/v5.5.1/api/
  2. https://blog.afi.io/blog/osrm-route-api-free-directions-api-with-turn-by-turn-directions-and-polylines/
  3. https://github.com/Project-OSRM/osrm-backend