API: Route could not be found - But Maps Finds One

I started in the python library, and have come back to the base API to confirm the same behavior. I am trying to route from an island back to the mainland, which has a ferry connection, but I cannot get the route returned in the API.

body = {“coordinates”:[[-70.0918500, 41.2767560],[-72.2648160, 41.8823860]]}
headers = {
‘Accept’: ‘application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8’,
‘Authorization’: api_key,
‘Content-Type’: ‘application/json; charset=utf-8’
}
call = requests.post(‘https://api.openrouteservice.org/v2/directions/driving-car/json’, json=body, headers=headers)

I receive this error:

{“error”:{“code”:2009,“message”:“Route could not be found - Unable to find a route between points 1 (-70.0918500 41.2767560) and 2 (-72.2648160 41.8823860).”},“info”:{“engine”:{“build_date”:“2024-12-02T11:09:21Z”,“graph_version”:“1”,“version”:“9.0.0”},“timestamp”:1738117008169}}

The same query into the map will generate a route. I did notice in the json, instead of graph_version:1, it has graph_date:2025-01-22T01:20:38Z. I copied the query syntax from the map gui and still get the same error above.
maps.openrouteservice.org

Anyone have pointers of where to look next?

Hey,

as far as I can tell, the route you linked is not the route you are querying in your code:

Best regards

Quick addendum as to why you cannot route from Nantucket back to the mainland:

Ferries starting at the Hy-Line Terminal are connected to the main network with a highway=footpath, essentially saying that this is only passable by foot.

Ferries starting at the Steamship Authority Terminal are connected by a

bridge=yes
ferry=yes
…

which is not taken into account for car routing, since there is no highway=* tag on it - essentially, it is saying “I am a bridge” and that is not enough to justify car routing.

You can have a look at skip_segments in our interactive API documentation, to possibly skip these segments.

Best regards

1 Like