Back to data catalog

Geocoding API

Geocoding and reverse-geocoding based on OpenStreetMap®-data

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 using JavaScript.

const response = await fetch(
	"https://api-test.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)

Example 2

Retrieving the coordinates of Berlin using Python.

from httpx import Client

with Client() as client:
    response = client.get(
        url="https://api-test.openepi.io/geocoding/",
        params={"q": "Berlin"},
    )

    data = response.json()

    # prints the coordinates of the first result
    print(data["features"][0]["geometry"]["coordinates"])

Example 3

Retrieving a location near the given coordinate using JavaScript.

const response = await fetch(
	"https://api-test.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)

Example 4

Retrieving a location near the given coordinate using Python.

from httpx import Client

with Client() as client:
    response = client.get(
        url="https://api-test.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"])