GraphHopper Directions API
With the you can integrate A-to-B route planning, turn-by-turn navigation, route optimization, isochrone calculations and other tools in your application.
The GraphHopper Directions API consists of the following RESTful web services:
- ,
- ,
- ,
- ,
- ,
- and
- .
Explore our APIs
Get started
Each API part has its own documentation. Jump to the desired API part and learn about the API through the given examples and tutorials.
In addition, for each API there are specific sample requests that you can send via Insomnia or Postman to see what the requests and responses look like.
Insomnia
To explore our APIs with , follow these steps:
- Open Insomnia and Import .
- Specify in your workspace: Manage Environments -> Base Environment ->
"api_key": your API key - Start exploring

Postman
To explore our APIs with , follow these steps:
- Import our as well as our .
- Specify in your environment:
"api_key": your API key - Start exploring

API Client Libraries
To speed up development and make coding easier, we offer the following client libraries:
- - try the
- like C#, Ruby, PHP, Python, ... automatically created for the Route Optimization API
Bandwidth reduction
If you create your own client, make sure it supports http/2 and gzipped responses for best speed.
If you use the Matrix, the Route Optimization API or the Cluster API and want to solve large problems, we recommend you to reduce bandwidth
by
and specifying the header as follows: Content-Encoding: gzip. This will also avoid the HTTP 413 error "Request Entity Too Large".
Contact Us
If you have problems or questions, please read the following information:
To stay informed about the latest developments, you can
- follow us on ,
- read ,
- watch ,
- sign up for our newsletter or
- .
Select the channel you like the most.
Map Data and Routing Profiles
Currently, our main data source is . We also integrated other network data providers. This chapter gives an overview about the options you have.
OpenStreetMap
Geographical Coverage
covers the whole world. If you want to see for yourself if we can provide data suitable for your region, please visit . You can edit and modify OpenStreetMap data if you find that important information is missing, e.g. a weight limit for a bridge. is a beginner's guide that shows how to add data. If you have edited data, we usually consider your data after 1 week at the latest.
Supported Vehicle Profiles
The Routing, Matrix and Route Optimization APIs support the following vehicle profiles:
Please note:
- all motor vehicles (
car,small_truck,truckandscooter) support turn restrictions viaturn_costs=true - the free package supports only the vehicle profiles
car,bikeorfoot - up to 2 different vehicle profiles can be used in a single optimization request. The number of vehicles is unaffected and depends on your subscription.
- we offer custom vehicle profiles with different properties, different speed profiles or different access options. To find out more about custom profiles, please .
- a sophisticated
motorcycleprofile is available up on request. It is powered by the Routing API and favors curves and slopes while avoiding cities and highways.
TomTom
If you want to include traffic, you can purchase the TomTom Add-on. This Add-on only uses TomTom's road network and historical traffic information. Live traffic is not yet considered. If you are interested to learn how we consider traffic information, we recommend that you read .
Please note the following:
- Currently we only offer this for our .
- In addition to our terms, you need to accept TomTom's .
- We do not use TomTom's web services. We only use their data with our software.
for more details.
Geographical Coverage
We offer
- Europe including Russia
- North, Central and South America
- Saudi Arabia
- United Arab Emirates
- South Africa
- Australia
Supported Vehicle Profiles
- Homepage
- https://api.apis.guru/v2/specs/graphhopper.com/1.0.0.json
- Provider
- graphhopper.com
- OpenAPI version
- 3.0.0
- Spec (JSON)
- https://api.apis.guru/v2/specs/graphhopper.com/1.0.0/openapi.json
- Spec (YAML)
- https://api.apis.guru/v2/specs/graphhopper.com/1.0.0/openapi.yaml
Tools (18)
Extracted live via the executor SDK.
-
clusterApi.asyncClusteringProblemPrefer the and use this Batch Cluster endpoint for long running problems only. The work flow is asynchronous:
- send a POST request towards
https://graphhopper.com/api/1/cluster/calculate?key=<your_key>and fetch the job_id. - poll the solution every 500ms until it gives
status=finished. Do this with a GET request towardshttps://graphhopper.com/api/1/cluster/solution/<job_id>?key=<your_key>.
- send a POST request towards
-
clusterApi.getClusterSolutionThis endpoint returns the solution of the clustering problems submitted to the . You can fetch it with the job_id, you have been sent.
-
clusterApi.solveClusteringProblemThe Cluster endpoint is used with a POST request towards
https://graphhopper.com/api/1/cluster?key=<your_key>. The solution will be provided in the JSON response. Please note that for problems that take longer than 10 seconds a bad request error is returned. In this case please use the asynchronous instead. -
geocodingApi.getGeocodeIntroduction

Geocoding describes the process of transforming an textual address representation to a coordinate (
latitude,longitude). For example the conversion fromBerlinto52.5170365,13.3888599.Reverse geocoding converts a coordinate to a textual address representation or place name. Find out more about Geocoding itself on .
-
isochroneApi.getIsochroneExample
You can get an example response via:
Don't forget to replace the placeholder with your own key.
Introduction

An isochrone of a location is ''a line connecting points at which a vehicle arrives at the same time'', see Wikipedia. With the same API you can also calculate isodistances, just use the parameter distance_limit instead of time_limit`.
Use Cases
Some possible areas in which this API may be useful to you:
- real estate analysis
- realtors
- vehicle scheduling
- geomarketing
- reach of electric vehicles
- transport planning
- logistics (distribution and retail network planning)
API Clients and Examples
See the section in the main documentation, and . `
-
mapMatchingApi.postGpxExample
You get an example response for a GPX via:
A minimal working GPX file looks like
Introduction

The Map Matching API is part of the GraphHopper Directions API and with this API you can snap measured GPS points typically as GPX files to a digital road network to e.g. clean data or attach certain data like elevation or turn instructions to it. Read more at Wikipedia.
In the example screenshot above and demo you see the Map Matching API in action where the black line is the GPS track and the green one is matched result.
Most of the times, you can simply POST a GPX file, but some of the request parameters of the apply here, too.
API Clients and Examples
See the section in the main documentation, and .
Limits and Counts
The cost for one request depends on the number of GPS location and is documented .
One request should not exceed the Map Matching API location limit depending on the package, see the pricing in our dashboard.
curl -XPOST -H "Content-Type: application/gpx+xml" "https://graphhopper.com/api/1/match?vehicle=car&key=[YOUR_KEY]" --data @/path/to/some.gpx<gpx> <trk> <trkseg> <trkpt lat="51.343657" lon="12.360708"></trkpt> <trkpt lat="51.343796" lon="12.361337"></trkpt> <trkpt lat="51.342784" lon="12.361882"></trkpt> </trkseg> </trk></gpx> -
matrixApi.calculateMatrixPrefer the and use this Batch endpoint for long running problems only.
The Batch Matrix endpoint allows using matrices with more locations and works asynchronously - similar to the :
- Create a HTTP POST request against
/matrix/calculateand add the key in the URL:/matrix/calculate?key=[YOUR_KEY]. This will give you thejob_idfrom the response json like{ "job_id": "7ac65787-fb99-4e02-a832-2c3010c70097" } - Poll via HTTP GET requests every 500ms against
/matrix/solution/[job_id]
Here are some full examples via curl:
Pick the returned
job_idand use it in the next GET requests:When the calculation is finished (
status:finished) the JSON response will contain the full matrix JSON undersolution:Please note that if an error occured while calculation the JSON will not have a status but contain directly the error message e.g.:
And the optional
hintsarray.$ curl -X POST -H "Content-Type: application/json" "https://graphhopper.com/api/1/matrix/calculate?key=[YOUR_KEY]" -d '{"points":[[13.29895,52.48696],[13.370876,52.489575],[13.439026,52.511206]]}'{"job_id":"7ac65787-fb99-4e02-a832-2c3010c70097"}$ curl -X GET "https://graphhopper.com/api/1/matrix/solution/7ac65787-fb99-4e02-a832-2c3010c70097?key=[YOUR_KEY]"{"status":"waiting"}$ curl -X GET "https://graphhopper.com/api/1/matrix/solution/7ac65787-fb99-4e02-a832-2c3010c70097?key=[YOUR_KEY]"{"solution":{"weights":[[0.0,470.453,945.414],[503.793,0.0,580.871],[970.49,569.511,0.0]],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}},"status":"finished"}{"message":"Cannot find from_points: 1"} - Create a HTTP POST request against
-
matrixApi.getMatrixWith this Matrix Endpoint you submit the points and parameters via URL parameters and is the most convenient as it works out-of-the-box in the browser. If possible you should prefer using the that avoids problems with many locations and can also gzip the request. (Note, that all endpoints return gzipped responses).
-
matrixApi.getMatrixSolutionThis endpoint returns the solution of a JSON submitted to the Batch Matrix endpoint. You can fetch it with the job_id, you have been sent.
-
matrixApi.postMatrixThe has an URL length limitation, which hurts for many locations per request. In those cases use this POST endpoint with a JSON as input. The only parameter in the URL will be the key. Both request scenarios are identical except that all singular parameter names are named as their plural for a POST request. The effected parameters are:
points,from_points,to_points, andout_arrays. For the remaining parameters please refer to the .Please note that in contrast to GET endpoint the points have to be specified as
[longitude, latitude]array (in that order, similar to ).For example the query
point=10,11&point=20,22&vehicle=carwill be converted to the following JSON:A complete curl Example:
-
routeOptimizationApi.asyncVrpTo solve a vehicle routing problem, perform the following steps:
1.) Make a HTTP POST to this URL
It returns a job id (job_id).
2.) Take the job id and fetch the solution for the vehicle routing problem from this URL:
We recommend to query the solution every 500ms until it returns 'status=finished'.
Note: Since the workflow is a bit more cumbersome and since you lose some time in fetching the solution, you should always prefer the . You should use the batch mode only for long running problems.
-
routeOptimizationApi.getSolutionTake the job id and fetch the solution for the vehicle routing problem from this URL:
You get the job id by sending a vehicle routing problem to the .
-
routeOptimizationApi.solveVrpTo get started with the Route Optimization API, please read the .
To solve a new vehicle routing problem, make a HTTP POST to this URL
It returns the solution to this problem in the JSON response.
Please note that this URL is very well suited to solve minor problems. Larger vehicle routing problems, which take longer than 10 seconds to solve, cannot be solved. To solve them, please use the instead.
-
routingApi.getRouteThe GET request is the most simple one: just specify the parameter in the URL and you are done. Can be tried directly in every browser.
-
routingApi.getRouteInfoUse this to find out details about the supported vehicle profiles and features, or if you just need to ping the server.
-
routingApi.postRoutePlease see the for a simpler method on how to get started. If you are familiar with POST requests and JSON then do not hesitate to continue here.
Especially when you use many locations you should get familiar with this POST endpoint as the GET endpoint has an URL length limitation. Additionally the request of this POST endpoint can be compressed and can slightly speed up the request.
To do a request you send JSON data. Both request scenarios GET and POST are identical except that all singular parameter names are named as their plural for a POST request. The effected parameters are:
points,point_hintsandsnap_preventions.Please note that in opposite to the GET endpoint, points are specified in the order of
longitude, latitude.For example
point=10,11&point=20,22will be converted to thepointsarray (plural):Note again that also the order changes from
[latitude,longitude]to[longitude,latitude]similar to .Example:
-
openapi.previewSpecPreview an OpenAPI document before adding it as a source
-
openapi.addSourceAdd an OpenAPI source and register its operations as tools








