Graphhopper using Python and Pandas


We are currently evaluating whether Graphhopper is helpful for our use case. I’m wondering if and how I can use a Python DataFrame to send a request to a local Graphhopper server that calculates the route and returns the route to me as an XML file (gpx), so that I can later plot this route with Folium.
Is there a documentation and a way without swagger?

The DataFrame is a list with start and destination coordinates of petrol stations, where each line corresponds to a route (i.e. start petrol station and destination petrol station). Now it would be nice to display the route to each of these endpoints. I think this should be possible with Graphhopper.
But how do I design the request?

First you need to find out if you need the Routing API or the Map Matching API.

If you specify type=gpx instead of type=json the response will be GPX:

I need the Routing API and I’d like to do that in Python. In principle I have coordinates of location A and location B and I want to send this request to my own Graphhopper server. The server calculates the route and sends the answer as json (gpx) format back. Doing so I am getting http error 405 from the graphhopper server.

url = ""
with open("test1.gpx", "rb") as f:
data =
response = + "point?vehicle=bike&points_encoded=false", headers=   {'Content-type': 'application/gpx+xml'}, data=data)
json_data = response.json()

The endpoint /maps is wrong. You need to use /route

ah right. Issue solved.

I also need to execute same exercise of plotting these routes in R studio.

My coordinates are contained in a data frame which is supposed run from an origin and would return to same location after reaching other lines of coordinates.

I would like to do this using the GraphHopper API but I haven’t seen a solution yet.

How do I design this?