
OpenStreetMap Has a Free API — Build Maps Without Google (No Key, No Billing)
Google Maps Charges $7 Per 1000 Requests. OpenStreetMap Charges $0. OpenStreetMap (OSM) is the Wikipedia of maps. Community-maintained, completely free, and it has multiple APIs for geocoding, routing, and tile rendering. Geocoding (Address to Coordinates) Nominatim is the free geocoder: import requests def geocode ( address ): r = requests . get ( " https://nominatim.openstreetmap.org/search " , params = { " q " : address , " format " : " json " , " limit " : 1 }, headers = { " User-Agent " : " MyApp/1.0 " }) if r . json (): result = r . json ()[ 0 ] return { " lat " : result [ " lat " ], " lon " : result [ " lon " ], " display " : result [ " display_name " ]} return None location = geocode ( " Eiffel Tower, Paris " ) print ( location ) # {lat: 48.858, lon: 2.294, display: Tour Eiffel, Paris, France} Reverse Geocoding (Coordinates to Address) def reverse_geocode ( lat , lon ): r = requests . get ( " https://nominatim.openstreetmap.org/reverse " , params = { " lat " : lat , " lon " : l
Continue reading on Dev.to Tutorial
Opens in a new tab




