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
.
1import io.openepi.geocoding.api.GeocodingApi;
2import io.openepi.geocoding.model.FeatureCollection;
3import io.openepi.common.ApiException;
4
5public class Main {
6 public static void main(String[] args) {
7 GeocodingApi api = new GeocodingApi();
8 try {
9 FeatureCollection response = api.geocodingGet("Berlin");
10
11 // Prints the coordinates of the first result
12 System.out.println(response.getFeatures().get(0).getGeometry().getPoint().getCoordinates());
13 } catch (ApiException e) {
14 System.err.println("Exception when calling GeocodingApi#geocodingGet");
15 e.printStackTrace();
16 }
17 }
18}
1const response = await fetch(
2 "https://api.openepi.io/geocoding/?" + new URLSearchParams({ q: "Berlin" })
3)
4const data = await response.json()
5
6// prints the coordinates of the first result
7console.log(data.features[0].geometry.coordinates)
8
1from httpx import Client
2
3with Client() as client:
4 response = client.get(
5 url="https://api.openepi.io/geocoding/",
6 params={"q": "Berlin"},
7 )
8
9 data = response.json()
10
11 # prints the coordinates of the first result
12 print(data["features"][0]["geometry"]["coordinates"])
13
Example 2
Retrieving a location near the given coordinate.
1import io.openepi.geocoding.api.GeocodingApi;
2import io.openepi.geocoding.model.FeatureCollection;
3import io.openepi.common.ApiException;
4import java.math.BigDecimal;
5
6public class Main {
7 public static void main(String[] args) {
8 GeocodingApi api = new GeocodingApi();
9 try {
10 BigDecimal lat = new BigDecimal("52.5200");
11 BigDecimal lon = new BigDecimal("13.4050");
12 FeatureCollection response = api.reverseGeocodingReverseGet(lat, lon, null, null);
13
14 // Prints the name of the first result
15 System.out.println(response.getFeatures().get(0).getProperties().getName());
16 } catch (ApiException e) {
17 System.err.println("Exception when calling GeocodingApi#reverseGeocodingReverseGet");
18 e.printStackTrace();
19 }
20 }
21}
1const response = await fetch(
2 "https://api.openepi.io/geocoding/reverse?" +
3 new URLSearchParams({
4 lon: "13.438596",
5 lat: "52.519854",
6 })
7)
8const data = await response.json()
9
10// prints the name of the first result
11console.log(data.features[0].properties.name)
12
1from httpx import Client
2
3with Client() as client:
4 response = client.get(
5 url="https://api.openepi.io/geocoding/reverse",
6 params={"lon": 13.438596, "lat": 52.519854},
7 )
8
9 data = response.json()
10
11 # prints the name of the first result
12 print(data["features"][0]["properties"]["name"])
13