How to query for house numbers in Python

Hello, and happy New Year to everyone.

I’m completely new to OSM, and a little bit lost concerning Nominatim, Overpass, etc.

I’d like to query all the house numbers on a given street in a given city. Ideally, I’d like to do this in Python. Should I be doing this in Overpass (I found a post that suggested this), or Nominatim, or some other tool?

If anyone could give me example code of how to this (again, ideally in Python, but if not I can deal with it), I’d be very grateful.

Thank you very much,

Good morning, and welcome to this forum and to OSM in general.
I do something remotely similar in the following way:
1/ get the data as an xml file from overpass, this can be done either in bash or in python
2/ interpret the data with a python script that uses an xml library (I think there are several)

Thank you, Jan. Could you please give me some example code to do this? Either just as an Overpass query, or Python code that sends the query and receives the XML data? I’d really appreciate it.


Sorry, I am not allowed to share the code - it is my employer’s intellectual property.
Besides, I feel not called upon to come and do your laundry - excuse me if that sounds rude, it is intended to be a broad friendly grin, while straightforward to understand :wink: .

If you would share some code of yours, I might perhaps comment on it. I’m not sure, though, if this is the right place for such discussions, perhaps some admin or moderator could comment?

No, you would not appreciate it as much as you think you would. I am also new to OSM, and I looked at the XML exports. I guess even with conservative estimates 90% of all that “data” you would throw away anyways.

Coming to OSM for postal address data, such as “house numbers” might not worth the effort, this is not Google Maps, the UPS or the FedEx. I used to work for one of them, their address database is protected business data.

Much like Jan Olieslagers, I do not care to work for free either, nor I care to waste my efforts. You want good data out of OSM be the first to put it in there. One bit into OSM, one bit into your own database. What you gain is insight and skills, what you earn is credibility and recognition.

If we did not care to learn, or gain credibility we would not be building maps.