Back to data catalog
Geocoding API
Geocoding and reverse-geocoding based on OpenStreetMap®-data
OpenAPI Spec
Specification of all endpoints available in the geocoding api.
Github
Explore the source code behind the geocoding api.
More info
Data sources
The API is exclusively fetching data from https://photon.komoot.io. The service is based on OpenStreetMap® data, which is licensed under the Open Data Commons Open Database License (ODbL), by the OpenStreetMap Foundation (OSMF).
Processing
The data obtained from https://photon.komoot.io is presented as is, without any further processing or modification.
Examples
Example 1
Retrieving the coordinates of Berlin
.
const response = await fetch(
"https://api.openepi.io/geocoding/?" + new URLSearchParams({ q: "Berlin" })
)
const data = await response.json()
// prints the coordinates of the first result
console.log(data.features[0].geometry.coordinates)
from httpx import Client
with Client() as client:
response = client.get(
url="https://api.openepi.io/geocoding/",
params={"q": "Berlin"},
)
data = response.json()
# prints the coordinates of the first result
print(data["features"][0]["geometry"]["coordinates"])
import io.openepi.geocoding.api.GeocodingApi;
import io.openepi.geocoding.model.FeatureCollection;
import io.openepi.common.ApiException;
public class Main {
public static void main(String[] args) {
GeocodingApi api = new GeocodingApi();
try {
FeatureCollection response = api.geocodingGet("Berlin");
// Prints the coordinates of the first result
System.out.println(response.getFeatures().get(0).getGeometry().getPoint().getCoordinates());
} catch (ApiException e) {
System.err.println("Exception when calling GeocodingApi#geocodingGet");
e.printStackTrace();
}
}
}
Example 2
Retrieving a location near the given coordinate.
const response = await fetch(
"https://api.openepi.io/geocoding/reverse?" +
new URLSearchParams({
lon: "13.438596",
lat: "52.519854",
})
)
const data = await response.json()
// prints the name of the first result
console.log(data.features[0].properties.name)
from httpx import Client
with Client() as client:
response = client.get(
url="https://api.openepi.io/geocoding/reverse",
params={"lon": 13.438596, "lat": 52.519854},
)
data = response.json()
# prints the name of the first result
print(data["features"][0]["properties"]["name"])
import io.openepi.geocoding.api.GeocodingApi;
import io.openepi.geocoding.model.FeatureCollection;
import io.openepi.common.ApiException;
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
GeocodingApi api = new GeocodingApi();
try {
BigDecimal lat = new BigDecimal("52.5200");
BigDecimal lon = new BigDecimal("13.4050");
FeatureCollection response = api.reverseGeocodingReverseGet(lat, lon, null, null);
// Prints the name of the first result
System.out.println(response.getFeatures().get(0).getProperties().getName());
} catch (ApiException e) {
System.err.println("Exception when calling GeocodingApi#reverseGeocodingReverseGet");
e.printStackTrace();
}
}
}