OpenCage API

⭐ Beginner's Pick Geocoding / API Key Intermediate HTTPS CORS
Varies by plan (check documentation)

Overview

OpenCage is a geocoding API that converts addresses into geographic coordinates (and vice versa) using open data sources including OpenStreetMap. It supports over 2,500 languages and scripts and provides very detailed address components in its responses. The free tier offers 2,500 requests per day, which is plenty for small projects.

💡

Beginner Tip

Use the `countrycode` parameter to restrict results to a specific country (e.g., countrycode=de for Germany) — this dramatically improves accuracy when you know where the address is. Always URL-encode your query string.

Available Data

IP address details
latitude and longitude
city and country
timezone
ISP information

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from OpenCage",
    "description": "Forward and reverse geocoding using open data",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

results Array of geocoding matches ordered by confidence score
results[].formatted Full human-readable formatted address of the result
results[].geometry Object containing lat and lng decimal coordinates of the location
results[].confidence Integer from 1 to 10 indicating match quality; 10 is the most confident
results[].components Structured address broken into parts like country, city, postcode, and road
rate.remaining Number of API calls remaining in the current 24-hour window

Implementation Example

const url = "https://opencagedata.com/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized API key is invalid or missing
Get a free key at https://opencagedata.com/users/sign_up and pass it as the key parameter
402 Payment Required You have exceeded the daily free tier limit of 2,500 requests
Implement local caching of geocoding results; reset happens at midnight UTC, or upgrade your plan
Low confidence results The query is ambiguous or lacks sufficient context
Add city, country, or postal code to the query string, or use the countrycode and bounds parameters to narrow results

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 17/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS YES
Category Geocoding
Difficulty Intermediate
Verified: 2026-04-04

Alternatives to OpenCage

Technical alternatives for different use cases.

Aggregates multiple geocoding sources for better coverage

Better For

Free usage without rate limits

Trade-off

Global geocoding with consistent quality

Similar APIs

View All →