{"id":21646,"library":"opencage","title":"OpenCage Geocoder","description":"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.","status":"active","version":"3.3.1","language":"python","source_language":"en","source_url":"https://github.com/OpenCageData/python-opencage-geocoder","tags":["geocoding","opencage","geolocation","api-wrapper"],"install":[{"cmd":"pip install opencage","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP requests to OpenCage API","package":"requests","optional":false}],"imports":[{"note":"Direct import is non-existent; must use OpenCageGeocode class","wrong":"from opencage import Geocoder","symbol":"Geocoder","correct":"from opencage.geocoder import OpenCageGeocode"}],"quickstart":{"code":"from opencage.geocoder import OpenCageGeocode\nimport os\n\nkey = os.environ.get('OPENCAGE_API_KEY', 'YOUR-API-KEY')\ng = OpenCageGeocode(key)\nresult = g.geocode('London')\nprint(result[0]['geometry'] if result else 'No results')","lang":"python","description":"Initialize with API key and geocode an address."},"warnings":[{"fix":"Access coordinates via result[0]['geometry']['lat'] and result[0]['geometry']['lng']","message":"In version 2.2.4, the API response format changed: 'lat' and 'lng' keys were moved inside 'geometry'. Old code accessing result[0]['lat'] will break.","severity":"breaking","affected_versions":"< 2.2.4"},{"fix":"Use `OpenCageGeocode(key)` where key is the API key string.","message":"API key must be passed as first positional argument, not as keyword. Using `OpenCageGeocode(api_key=...)` will raise an unexpected keyword argument error.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `from opencage.geocoder import Geocoder` with `from opencage.geocoder import OpenCageGeocode`","message":"The 'Geocoder' class alias in opencage.geocoder was deprecated in 2.2.0 and removed in 3.0.0. Use 'OpenCageGeocode' instead.","severity":"deprecated","affected_versions":">= 3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `OpenCageGeocode('your-api-key')` instead of `OpenCageGeocode(api_key='your-api-key')`","cause":"Trying to pass API key as keyword instead of positional argument","error":"opencage.geocoder.OpenCageGeocode.__init__() got an unexpected keyword argument 'api_key'"},{"fix":"Install with `pip install opencage` and import from `opencage.geocoder`","cause":"Library not installed or installed under different name (e.g., opencage-geocoder)","error":"ModuleNotFoundError: No module named 'opencage'"},{"fix":"Access coordinates via result[0]['geometry']['lat'] and result[0]['geometry']['lng']","cause":"Using old response format expecting 'lat' at top level; now inside 'geometry'","error":"KeyError: 'lat'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}