The Geocoding API finds the coordinates of an address or place name, for example 52.5170365,13.3888599 for Berlin. With reverse=true, it finds addresses and place names near a coordinate.
You can choose between several providers. They differ in their data and in what they do well, so it is worth trying them on your own addresses:
- GraphHopper (
default): our own geocoder on OpenStreetMap data. It also matches the beginning of words, which suits autocomplete, where a user types an address into a search field. - Nominatim (
nominatim): the Nominatim geocoder on OpenStreetMap data, hosted by OpenCage. It suits complete addresses without user interaction, such as batch processing, but not autocomplete. - OpenCage (
opencagedata): the OpenCage geocoder, which combines Nominatim with other sources.
You select a provider with the provider parameter. All providers return the same response structure, but not every provider fills every field, and some parameters work with one provider only.
Free plans can use the GraphHopper provider only. The credit cost of a request depends on the provider, see What is one credit?
To find the coordinates of an address or place name, pass it as q. To find addresses and places near a coordinate, pass reverse=true and the coordinate as point.
The address or place name to search for. Required unless reverse=true. The default provider also matches the beginning of words, which suits autocomplete, but can give worse results for complete addresses without user interaction. For those, consider provider=nominatim.
The language of the names in the results, as a language code such as de. The default provider supports cs, de, en, es, fr, hu, it, pl, pt, ru, sk and uk. Without locale, or with another language, it returns each name in the local language. The nominatim and opencagedata providers return English names without locale.
The geocoder that answers the request; the Geocoding introduction compares them.
Only returns results with this OpenStreetMap tag, given as key:value or just key, for example tourism:museum or tourism. With ! in front, excludes results with this tag instead, for example !place. Repeat the parameter for several tags. Supported by the default provider only.
- https://graphhopper.com/api/1https://graphhopper.com/api/1/geocode
curl "https://graphhopper.com/api/1/geocode?q=berlin&locale=de&key=api_key"{ "hits": [ { "point": { "lat": 52.5173885, "lng": 13.3951309 }, "extent": [ 13.088345, 52.3382448, 13.7611609, 52.6755087 ], "name": "Berlin", "country": "Deutschland", "countrycode": "DE", "osm_id": 62422, "osm_type": "R", "osm_key": "place", "osm_value": "city" }, { "point": { "lat": 54.006485, "lng": 61.192986 }, "extent": [ 61.165329, 53.9964889, 61.2099869, 54.0146863 ], "name": "Berlin", "country": "Russland", "countrycode": "RU", "state": "Oblast Tscheljabinsk", "postcode": "457130", "osm_id": 261333127, "osm_type": "W", "osm_key": "place", "osm_value": "village" }, { "point": { "lat": 44.4696602, "lng": -71.1810703 }, "extent": [ -71.397858, 44.445057, -71.123642, 44.528436 ], "name": "Berlin", "country": "Vereinigte Staaten von Amerika", "countrycode": "US", "state": "New Hampshire", "postcode": "03570", "osm_id": 170184, "osm_type": "R", "osm_key": "place", "osm_value": "city" }, { "point": { "lat": 39.7589387, "lng": -89.9031635 }, "extent": [ -89.912101, 39.750371, -89.893165, 39.764932 ], "name": "Berlin", "country": "Vereinigte Staaten von Amerika", "countrycode": "US", "state": "Illinois", "osm_id": 126290, "osm_type": "R", "osm_key": "place", "osm_value": "village" }, { "point": { "lat": 41.621488, "lng": -72.7456519 }, "extent": [ -72.8397657, 41.5537205, -72.7110151, 41.6527197 ], "name": "Berlin", "country": "Vereinigte Staaten von Amerika", "countrycode": "US", "state": "Connecticut", "osm_id": 11042445, "osm_type": "R", "osm_key": "place", "osm_value": "town" } ], "locale": "de" }