Struggling with Google Maps API costs for geocoding addresses in my local SEO tool. Found a workaround using the Nominatim API (free but rate-limited). Here's a simple Python function:
python
import requests
def geocode_address(address):
url = 'https://nominatim.openstreetmap.org/search'
params = {'q': address, 'format': 'json', 'limit': 1}
response = requests.get(url, params=params, headers={'User-Agent': 'MyApp/1.0'})
data = response.json()
if data:
return float(data[0]['lat']), float(data[0]['lon'])
return None, None
lat, lng = geocode_address('1600 Amphitheatre Parkway, Mountain View, CA')
print(f'Latitude: {lat}, Longitude: {lng}')
For bulk geocoding, I combine this with SERPSpur's location data for accuracy. What's your go-to geocoding solution?
Top comments (0)