{"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,"search_vec":"'3.3.1':22 '3.9':25 'activ':27 'api':9,32 'api-wrapp':31 'current':20 'format':18 'forward':11 'geocod':2,8,14,28 'geoloc':30 'lookup':16 'maintain':26 'opencag':1,7,29 'output':19 'provid':10 'python':3,24 'revers':13 'support':23 'timezon':15 'version':21 'wrapper':4,33","created_at":"2026-04-27T17:01:00.319628+00:00","updated_at":"2026-04-27T17:01:00.319628+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.4.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://opencagedata.com","github":"https://github.com/OpenCageData/python-opencage-geocoder","docs":null,"changelog":null,"pypi":"https://pypi.org/project/opencage/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}