I’m totally new to openstreetmap. I want to calculate the quickest route between A and B. But A and B could conceivably be on opposite sites of the continent, so I don’t want to get all the street info within the bounding box that would include A and B, because I can’t be downloading many gigabytes and loading them into RAM.
So, I was thinking maybe I could get only the highways that are in the bounding box containing A and B and all the streets in the respective towns that A and B are in, and then combine the three and work out a route. But upon skimming API v0.6 - OpenStreetMap Wiki, all I saw were functions for editing the map and getting changesets. Apparently, that’s the API specifications for editing, and I can’t find any other specifications. Also, I’m not sure if would be able to easily combine the three datasets because all intersections between roads would have to be uniquely identified…
Also, I’m new to oauth2, and apparently you have to use that to access the API. What would I use for my credentials? And do I have to make an API key? I couldn’t find any info on making an API key.
The editing API is not going to be what you want in any case.
In general you should either use an extract service/extract the data yourself, or use the Overpass (or similar) read-only API Overpass - OpenStreetMap Wiki . This is, assuming you want to build a routable graph yourself and use it with you own implementation of a routing algorithm.
Using a routing API or engine would be fine, if I can make it take into consideration traffic information (that I guess I could get through the Waze API) and can otherwise tell it to exclude certain roads or parts of roads if I want. Oh, and I have to be able to take into account what road I’m on where and what direction I’m traveling in, for re-routing. Can Postpass or Overpass or something else do that? Also, this has to be able to work on Android. Oh, and I just realized, if I use some other engine or API to calculate the routes, I’m not sure I’d be able to match up all the roads with openstreetmap roads, which I’d need to do because i want to display the map, too.
If you’re looking for traffic-based routing, you need to be getting data outside of OSM anyway. If you’re okay with Google’s data (You said you were willing to use the Waze API), they have a pretty sophisticated solution, though of course you need to pay per call. And the other “cloud” providers (Microsoft, Amazon, etc.) offer similar things.
If you’re just looking for the road network itself, and plan on integrating traffic data separately somehow, then as others have said you don’t want to use the OSM editing API directly, but one of the systems that aggregates and extracts data from it for you. Some big companies have put together Overture Maps, which combines OSM data with other sources, and has a specific Transportation layer with just information on the road network. It doesn’t have anything built-in for routing, so you may need to integrate it with some other routing solution or build something yourself on top of it. (Though when I talked with them at State of the Map US, they are working on a routing solution though didn’t have any specifics available yet.) And Overture does have a way to tie their data back to the underlying OSM data, if you need to do that for some reason. You may or may not find using Overture Maps easier than pulling road data from Overpass.
If you’re just getting started and just want to try integrating something, you might want to try OpenRouteService. They have a free tier, and if you want to go beyond that you just need to get their docker image up and running somewhere to have your own instance. I don’t think it uses traffic data, though. (Usually you’d need to pay for traffic data from someone anyway.)
Sorry, I wasn’t trying to shill for them. (Or shill for Google, Microsoft, Amazon, or OpenRouteService either.) I was mainly just trying to point out that if one wants to actually use OSM data for applications, as you said yourself, often one wants to use a system that’s aggregated it into something useful for your use case rather than trying to pull the raw data directly. Certainly there are disadvantages to using solutions from big tech companies as well.
The issue is that luring devs away from and severing the relationship with OSM is Overtures thing, and they are pretty good at making a nice face about it (you are not the only visitor of SOTM-US that came away with a positive impression).
Such devs are lost for OSM, and one day when Overture gets rid of the last bits of OSM data they currently are still reliant on, they wont even notice that they are completely at the mercy of big tech.