Routing API
Geoapify's Road Routing API makes it easy to calculate a route between two or more waypoints for cars, trucks, bicycles, walking, and transit. Our API returns the route object with route geometry in GeoJSON format.
Results include:
- Route directions (or turn-by-turn instructions)
- Exact travel time and distance between locations
- Route details including elevation profiles, road properties and restrictions
Our API gives you all the information you need to plan trips for vehicles and people. Whether you want to plan a driving route for your fleet, a package delivery route, a hiking route for your vacation, or something else, our API has you covered.
On this page
Try Routing API
Click on the map to set a starting point and destination points, choose the transportation mode - car, truck, bicycle, pedestrian, or transit:
Try out different options and travel modes in our Routing API Playground. Get an API key and get started today. We offer Freemium pricing so you can get started right away for free, and buy a different package when you need it.
Road Routing Use Cases
Get driving or walking routes between waypoints
Our Road Routing gives you driving or walking route geometry, along with route length and duration. Easily estimate the real distance and time between provided waypoints, and visualize the route on a map.
Get navigation instructions
The API returns turn-by-turn navigation instructions for each route, so you can use the API alongside GPS tools. Request detailed navigation including street names, and detailed information about maneuvers. Routing API supports many languages, so you can use the “lang” input parameter to define your language.
{
"text": "Turn right onto East 14th Street.",
"type": "Right",
"transition_instruction": "Turn right. Then Bear left toward Interstate 70 West.",
"pre_transition_instruction": "Turn right onto East 14th Street. Then Bear left toward Interstate 70 West.",
"post_transition_instruction": "Continue for 60 meters.",
"streets": ["East 14th Street"]
}
Route analysis
As well as directions, our API gives you practical route information. Use the “route_details” parameter to get detailed information and analyze how good the route is. Get details about road class and surface, number of lanes, and how many maneuvers each route will take. Route analysis information helps you make decisions about route efficiency, fuel consumption, and ease of driving or walking.
{
"speed": 40,
"speed_limit": 40,
"truck_limit": 40,
"surface": "paved_smooth",
"lane_count": 3,
"road_class": "secondary",
"name": "East 10th Street",
"toll": false,
"tunnel": false,
"bridge": false,
"roundabout": false,
"rightside": true,
"traversability": "forward",
"elevation": 286
}
Calculate and preview hiking and mountain biking routes
Use Routing APi to calculate and preview hiking or mountain biking routes. Get a feel for the terrain before you even set out. You can also request elevation information to create elevation profile visualizations. These are helpful for any hiking or biking route, especially among mountains.
Need to estimate distance and travel time for multiple locations?
Our Route Matrix API returns time/distance for multiple locations, up to 1000 values at once.
Need to reconstruct a route from its GPS coordinates?
Our Map Matching API lets you put in GPS coordinates, and matches them to existing roads. You get route geometry alongside route details.
Features and capabilities
Support a variety of travel modes
Routing API supports multiple travel modes and vehicle types. That means you get a route that's tailor made to your specific conditions. Supported modes include:
Mode | Description |
---|---|
Driving | A passenger car with a maximum weight of 3.5 tonnes and a maximum height of 1.6 meters. |
Light Truck | Suitable for a larger passenger car, small delivery truck, camper van, or other van, with a maximum weight of 3.5 tonnes and a maximum height of 3.2 meters. |
Medium truck | A medium sized truck such as a delivery vehicle with a maximum weight of 7.5 tonnes and a maximum height of 4 meters. |
Truck | A standard full size truck with a maximum weight of 22 tonnes and a maximum height of 4 meters. |
Heavy truck | A heavyweight vehicle weight up to 40 tonnes. |
Truck carrying dangerous goods | Suitable for trucks carrying dangerous good such as flammables, explosives, or solvents, with a maximum weight of 22 tonnes and a maximum height of 4 meters. |
Long truck | Suitable for longer vehicles with a length up to 34 meters. |
Bus | Our APi will help you find lanes and roads with bus only access. |
Scooter | Put together routes for motor scooters and mopeds. |
Motorcycle | Suitable for motorcycle riders, helping you to find suitable road classes to drive safely. |
Bicycle | Find routes that work for city bicycles that are built to ride on roads and paths with good surfaces. |
Mountain bicycle | Suitable for off-road use, but slower on roads. Our API takes road time into account. |
Road bicycle | Road bikes have narrow tires and lightweight frames. Use our API to find the best roads to travel to your destination. |
Walk | Getting to your destination on foot? Our API still has your back. Pedestrian mode is set to a speed of 5 km/hour. |
Hike | Our specialized hiking mode uses hiking trails and more difficult paths than our walking mode. |
Transit | Find the best way to reach your destination using transit or public transport. |
Skip gates, roads, and even countries
Our Routing API lets you set barriers around specific locations, so the API won't build a route through them. You can skip tunnels and bridges, or set it to avoid specific roads. You can even set it to avoid specific countries, for example in areas where some routes might cross a border and come back again.
Here is an example URL that shows how to add barriers on the roads:
https://api.geoapify.com/v1/routing?mode=drive&avoid=location:36.081202,-79.475436&waypoints=36.08017014270986,-79.48035675866345|36.08253462115621,-79.45918129233303&apiKey=YOUR_API_KEY
Here is the result of a call to the Routing API:
Avoid unwanted route parts
If you want to avoid specific route parts such as toll roads, ferries, or highways, you can. The Routing API makes it easy to avoid specific parts. If you don't want to go down a toll road, or take your vehicle onto a ferry, the API makes it easy to avoid that. And if an unwanted route part comes up between your destinations, the API will offer you alternative routes if possible.
Here is an URL that uses the Avoid Toll Roads and Avoid Highways parameters:
https://api.geoapify.com/v1/routing?mode=drive&avoid=tolls|highways&waypoints=40.709398574687725,-74.08840443457757|40.81123976392868,-72.88224315187449&apiKey=YOUR_API_KEY
Get directions and instructions
Every route result includes navigation instructions to guide you to your destination. For example, “Drive west on Freisinger Straße/DAH 9” or “Enter the roundabout and take the 2nd exit”. The API supports instructions in English, German, Italian, Spanish, French, and other languages.
See elevation profiles
Ask the API for a route elevation profile to determine how much elevation you'll gain on your route. This is great for bike and hiking routes so you know ahead of time what to expect. Knowing a route's elevation helps you determine its difficulty.
Easy to use and permissive
Our routing API is accessible via HTTP GET requests and easy to integrate with any programming language. Results are returned as GeoJSON objects. Because our Routing API is based on open data, you can store and redistribute your results.
Getting started
Getting started with Routing API is easy:
Step 1. Register and get an API Key
You'll need an API key to get started. Register on Geoapify MyProjects and get an API key.
Step 2. Generate and call HTTP Get request
Generate an HTTP Get request with input data and make the call. Use our Playground and Documentation to learn about Routing API request/response structure.
Here's an example of a Routing API URL that calculates a route between 5 waypoints for bicycle:
https://api.geoapify.com/v1/routing?waypoints=47.569664,10.7021002|47.575734,10.720492|47.567089,10.733584|47.557827,10.749579|47.544780,10.722865&mode=bicycle&apiKey=YOUR_API_KEY
Here is the response object returned by the API call:
- [] 1 item▶
- {} 3 keys▶
- "Feature"
- {} 5 keys▶
- {} 2 keys▶
- {} 2 keys▶
- "bicycle"
- [] 5 items▶
- "FeatureCollection"
The response has one feature of MultiLineString. The feature properties contain waypoints and route legs. Each route leg includes time/distance information and Directions instructions.
The code samples below show you how to make an API call with different programming languages:
- JavaScript
- Angular
- Node.js-fetch
- Python
- cURL
fetch('https://api.geoapify.com/v1/routing?waypoints=48.184731,11.547931|48.168254,11.581501|48.179391,11.612174&mode=drive&apiKey=YOUR_API_KEY')
.then(resp => resp.json())
.then((calculatedRouteGeoJSON) => {
console.log(calculatedRouteGeoJSON);
});
Routing API tutorials
Check out our tutorials to make it easy to get started and get the results you want with Routing API:
How to use the Route Directions API
How to draw routes on a Maplibre GL (Mapbox GL) map
Drawing Route Elevation Profile with Chart.js
Still not sure how to start? If you're facing any problems or have questions, we're here to help! Contact us and we will be happy to assist.
How Much Does It Cost?
We offer Affordable Prices for businesses of all sizes. Our free plan includes up to 3000 credits a day. Each API call costs a certain number of credits:
- Each pair of waypoints costs 1 credit.
- Each 500 kilometers of the resulting route length costs an additional credit, if the route length is more than 500 kilometers.
Use our Pricing Calculator to estimate how many credits you need.
Read more about how we calculate costs here.
FAQ
How do you bill Directions API Requests?
A route between every pair of waypoints is counted as a credit. Learn more about the API pricing on the API Documentation page.
How is 'Truck' mode different from 'Drive' mode?
Truck mode takes into account truck-specific road restrictions, and avoids narrow roads and residential areas. It also prioritizes routes with fewer maneuvers.
I need to build routes for heavy transport. Can your API do that?
The Geoapify Routing API has a very flexible and powerful engine under the hood. Contact us and we will create a solution that works for your business.
How good is coverage for public transport?
We provide worldwide coverage for public transport. We use official GTFS feeds when they are available and approximated models for other places.
Can we use custom GTFS feeds with your Routing API?
Sure! We can set up a dedicated server for you that builds routes with your GTFS feeds.
Can you provide custom conditions for high volumes?
Yes! Contact us and we'll work out a plan that suits your needs
Ready To Get Started?
Need help getting started or want to discuss your specific needs? Get in touch and our team will be happy to help.