API Directory › 🌍 Geo & Location › OpenCage
API KeyHTTPSCORS

OpenCage API

Forward and reverse geocoding aggregating many open data sources.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open OpenCage docs ↗

What it does

OpenCage is a forward and reverse geocoding API that aggregates many open datasets (OpenStreetMap, Natural Earth, government sources) behind one clean interface, and enriches every result with annotations: timezone, currency, calling code, sun times, Mercator coordinates and more.

Base URL

https://api.opencagedata.com/geocode/v1/json

Authentication

Sign up for a key and pass it as ?key=YOUR_KEY. The free trial key is generous enough for development and small sites.

Code examples

curl (forward)
curl -s "https://api.opencagedata.com/geocode/v1/json?q=Brandenburg+Gate,Berlin&key=$OC_KEY"
Python (reverse)
import requests

r = requests.get("https://api.opencagedata.com/geocode/v1/json",
    params={"q": "52.5163,13.3777", "key": KEY, "no_annotations": 0}, timeout=10)
res = r.json()["results"][0]
print(res["formatted"])
print(res["annotations"]["timezone"]["name"],
      res["annotations"]["currency"]["iso_code"])

Rate limits & quotas

Free trial: 2,500 requests/day at 1 request/second. The response rate object reports your remaining quota and reset time. Over the limit returns HTTP 402 (quota) or 429 (per-second). Batch by looping — there is no bulk endpoint, but the per-second limit is the only constraint.

Key response fields

results[].geometry.lat / lngCoordinates of the match
results[].formattedHuman-readable full address
results[].componentsStructured parts: road, city, postcode, country…
results[].confidence1–10 rough accuracy score
results[].annotationsTimezone, currency, calling code, what3words, sun times

Common errors

401Missing or invalid key.
402Daily quota used up — resets at midnight UTC.
429Exceeded 1 request/second — throttle.
400 / results: []Ungeocodable or empty query — check status and result count.

When to use it (and alternatives)

A great middle ground: cleaner and better-documented than raw Nominatim, with permissive terms (you may store results), and the annotations save you extra API calls. For map tiles and routing you still need Mapbox.

FAQ

Can I cache or store OpenCage results?

Yes — OpenCage explicitly permits storing geocoding results, which many providers forbid. This makes it well suited to building your own address database.

Forward and reverse use the same endpoint?

Yes. Pass a place string for forward geocoding or "lat,lng" for reverse — the API figures out which you meant.

What are annotations good for?

They turn one geocode call into timezone, currency and calling-code lookups too — useful for localisation. Set no_annotations=1 to skip them and shrink the response.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

IP LookupDNS Lookup

Related Geo & Location APIs

← Back

More Geo & Location APIs · All 196 APIs