Skip to content

OpenCage API

by opencagedata.com

API keyHTTPSCORSGeocoding
Open documentation ↗

Overview

Forward and reverse geocoding using open data

OpenCage is a geocoding API from opencagedata.com. Requests are authenticated with an API key. It is served over HTTPS and allows browser requests (CORS). Its OpenAPI description documents 1 endpoints.

At a glance

Authentication
API key
HTTPS
Yes
CORS
Yes
Category
Geocoding
Base URL
https://api.opencagedata.com/geocode
Version
1
Endpoints
1
Spec updated
2023-03-06

Make a first request

Replace the placeholders; the documentation says exactly where credentials go.

cURL
curl -X GET "https://api.opencagedata.com/geocode/vVERSION/FORMAT" \
  -H "Accept: application/json" \
  -H "X-API-Key: YOUR_API_KEY"
JavaScript
const response = await fetch("https://api.opencagedata.com/geocode/vVERSION/FORMAT", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "X-API-Key": "YOUR_API_KEY",
  },
});
const data = await response.json();
console.log(data);
Python
import requests

response = requests.request(
    "GET",
    "https://api.opencagedata.com/geocode/vVERSION/FORMAT",
    headers={
    "Accept": "application/json",
    "X-API-Key": "YOUR_API_KEY",
    },
    timeout=30,
)
print(response.json())

Endpoints

MethodPathWhat it does
GET/v{version}/{format}geocode a query

Questions

Does the OpenCage API need an API key?

Yes. The OpenCage API uses API key authentication; the documentation explains how to get credentials.

Can I call the OpenCage API from the browser?

Yes. The OpenCage API sends CORS headers, so a web page can call it directly with fetch().

Does the OpenCage API support HTTPS?

Yes, the OpenCage API is served over HTTPS.

How many endpoints does the OpenCage API have?

Its OpenAPI description lists 1 endpoint in version 1. All of them are shown on this page.

What are alternatives to the OpenCage API?

Other Geocoding APIs include Bing Maps, ip-api, OpenStreetMap, GeographQL, IP Address Details.

Compare alternatives →

Listed from public-apis (MIT), public-apis database (MIT), APIs.guru (CC0).