Python wrapper for the OpenCage Geocoder API. Provides forward and reverse geocoding, timezone lookups, and formatted output. Current version: 3.3.1, supports Python >=3.9, maintained actively.
pip install opencageVerified import paths — ran on the pinned version, not inferred.
Initialize with API key and geocode an address.
Access coordinates via result[0]['geometry']['lat'] and result[0]['geometry']['lng']
Use `OpenCageGeocode(key)` where key is the API key string.
Replace `from opencage.geocoder import Geocoder` with `from opencage.geocoder import OpenCageGeocode`
Use `OpenCageGeocode('your-api-key')` instead of `OpenCageGeocode(api_key='your-api-key')`Install with `pip install opencage` and import from `opencage.geocoder`
Access coordinates via result[0]['geometry']['lat'] and result[0]['geometry']['lng']