Overview
OpenCage offers a geocoding and reverse geocoding API that converts human-readable addresses into geographic coordinates (latitude and longitude) and translates coordinates back into addresses. The service aggregates data from various open data sources, primarily OpenStreetMap project data, which provides a transparent and community-maintained foundation for its location services. This approach differentiates OpenCage by emphasizing open data principles and offering a clear understanding of the underlying information.
The API is suitable for developers and organizations that require global address lookup capabilities without proprietary data lock-in. It is particularly beneficial for applications in logistics, mapping, location-based analytics, and data enrichment where precise coordinate conversion is necessary. OpenCage supports a wide range of input formats for addresses and provides structured JSON responses, making it adaptable for various use cases. Its reverse geocoding functionality allows applications to display contextual location information from GPS coordinates, enhancing user experience in mobile and web applications.
OpenCage's developer experience is designed for ease of integration, offering client libraries (SDKs) in multiple programming languages, including Python, Ruby, PHP, Node.js, Java, Go, Elixir, Rust, and C#. This broad support facilitates rapid development and integration into existing technology stacks. The API documentation provides clear examples and explanations, guiding developers through common tasks such as basic geocoding requests, handling specific country biases, and managing rate limits. The service also includes features like language localization for results, allowing applications to display addresses in the preferred language of the end-user, which is crucial for international deployments. For example, a request can specify a language parameter to receive results in French or German, improving the relevance and usability of the output for local audiences.
The service's commitment to open data sources means that users benefit from the continuous updates and improvements made by the global OpenStreetMap community. This collaborative model often leads to more detailed and up-to-date mapping information in many regions compared to some proprietary datasets. The API also includes features like batch geocoding for processing multiple addresses efficiently and IP address geocoding, which can infer a user's approximate location based on their IP address. This flexibility makes OpenCage a versatile tool for a range of geospatial challenges, from simple address lookups to complex location intelligence applications.
Key features
- Geocoding API: Converts street addresses, place names, or postal codes into geographic coordinates (latitude and longitude). Supports global addresses with varying levels of specificity.
- Reverse Geocoding API: Translates geographic coordinates back into human-readable addresses, providing context such as street name, city, and country. Useful for displaying location information from GPS data.
- Open Data Source Integration: Utilizes data from OpenStreetMap and other open data projects, ensuring transparency and community-driven updates for geocoding results.
- Language Localization: Allows specifying a preferred language for geocoding results, enabling applications to display addresses in the local language of users globally. Refer to the OpenCage language parameter documentation for supported codes.
- Batch Geocoding: Supports processing multiple geocoding requests in a single call, optimizing efficiency for large datasets and reducing API call overhead.
- IP Address Geocoding: Provides approximate location information based on an IP address, useful for initial user localization or fraud detection.
- Developer-Friendly SDKs: Offers client libraries in Python, Ruby, PHP, Node.js, Java, Go, Elixir, Rust, and C# to streamline integration and development efforts.
- GDPR Compliance: Adheres to General Data Protection Regulation (GDPR) standards, ensuring data privacy and protection for users within the EU and globally.
Pricing
OpenCage offers a free tier for initial development and testing, with paid plans scaled by the number of daily requests. Custom enterprise pricing is available for high-volume requirements.
| Plan | Monthly Requests | Price (USD/month) | Features |
|---|---|---|---|
| Free | 2,500/day | $0 | Basic geocoding, rate limits apply |
| Developer | 50,000/day | $50 | Standard geocoding, email support |
| Small Business | 250,000/day | $250 | Enhanced geocoding, priority support |
| Enterprise | Custom | Custom | High volume, dedicated support, SLAs |
Pricing information is accurate as of 2026-05-28. For the most current details, refer to the OpenCage pricing page.
Common integrations
- Web Applications: Integrate with front-end frameworks (e.g., React, Angular, Vue.js) to provide real-time address suggestions or map displays. Developers can use the OpenCage JSON API reference for implementing autocomplete features.
- GIS Platforms: Connect with Geographic Information Systems (GIS) for data enrichment, adding coordinate data to existing spatial datasets.
- E-commerce Platforms: Use for validating shipping addresses or calculating delivery zones, enhancing checkout processes.
- Logistics and Delivery Systems: Integrate to optimize routing, track assets, and manage delivery operations by converting addresses to precise coordinates.
- CRM Systems: Enrich customer records with accurate location data for targeted marketing or service delivery.
- Data Analytics Tools: Combine with business intelligence platforms to perform location-based analysis and visualize geographical trends.
Alternatives
- Google Maps Platform Geocoding API: A comprehensive geocoding service known for its global coverage and integration with the broader Google Maps ecosystem, offering robust features for address lookup and reverse geocoding.
- Mapbox Geocoding API: Provides global geocoding and reverse geocoding services, often favored for its customizable maps and integration with other Mapbox services for location-based applications. The Mapbox Geocoding API documentation details its capabilities.
- LocationIQ Geocoding API: Offers geocoding and reverse geocoding solutions built on OpenStreetMap data, similar to OpenCage, providing a cost-effective alternative with a focus on ease of use and developer accessibility.
Getting started
This Python example demonstrates how to perform a basic geocoding request using the requests library to query the OpenCage API. Replace YOUR_API_KEY with your actual API key obtained from the OpenCage website.
import requests
import json
API_KEY = 'YOUR_API_KEY' # Replace with your actual OpenCage API key
query = '1600 Amphitheatre Parkway, Mountain View, CA'
url = f"https://api.opencagedata.com/geocode/v1/json?q={query}&key={API_KEY}"
try:
response = requests.get(url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
data = response.json()
if data and data['results']:
first_result = data['results'][0]
geometry = first_result['geometry']
formatted_address = first_result['formatted']
print(f"Formatted Address: {formatted_address}")
print(f"Latitude: {geometry['lat']}")
print(f"Longitude: {geometry['lng']}")
else:
print("No results found for the query.")
except requests.exceptions.RequestException as e:
print(f"Error during API request: {e}")
except json.JSONDecodeError:
print("Error decoding JSON response.")
This script sends a GET request to the OpenCage geocoding endpoint with a specified address query and your API key. It then parses the JSON response to extract the formatted address, latitude, and longitude of the first result. Error handling is included to manage potential issues with network requests or JSON parsing.