Skip to content

Geocoding

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?

Operations

Geocode an address or reverse geocode a coordinate

Request

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.

Security
key
Query parameters
qstring, <= 199 characters

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.

Example:q=Berlin
reverseboolean

If true, finds addresses and places near point, and ignores q.

Default:false
pointstring

A coordinate as latitude,longitude. With reverse=true, it is required: the coordinate to find addresses and places near. Otherwise, the default provider ranks results near it higher, see location_bias_scale and zoom.

Example:point=52.5170365,13.3888599
localestring

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.

Example:locale=de
limitinteger, (int32), <= 100

The maximum number of results. At most 10 on free plans, and at most 5 with geometry=true.

Default:5
providerstring

The geocoder that answers the request; the Geocoding introduction compares them.

Default:"default"
Enum:"default""nominatim""opencagedata"
osm_tagArray of strings

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.

Example:osm_tag=tourism:museum
bboxstring

Only returns results inside this box, given as minLon,minLat,maxLon,maxLat. Not with reverse=true. Supported by the default provider only.

Example:bbox=13.08,52.33,13.77,52.68
location_bias_scalenumber, (double), [ 0 .. 1 ]

How much the prominence of a result still counts next to its distance from point, from 0 (hardly at all) to 1 (about as much as the distance). Not with reverse=true. Supported by the default provider only.

Default:0.2
zoominteger, (int32)

How large the area around point is in which results rank higher, as a map zoom level: the higher, the smaller the area. Not with reverse=true. Supported by the default provider only.

Default:16
radiusnumber, (double)

The search radius around point in kilometers. Only with reverse=true. Supported by the default provider only.

Default:1
geometryboolean

If true, each result also contains its outline as geometry, where one is known. limit is then at most 5. Supported by the default provider only.

Default:false
countrycodestring

Only returns results in this country, given as a two-letter ISO 3166-1 code such as de. Supported by the nominatim and opencagedata providers.

Example:countrycode=de
boundsstring

Prefers results inside this box, given as minLon,minLat,maxLon,maxLat. Supported by the nominatim and opencagedata providers.

Example:bounds=13.08,52.33,13.77,52.68
curl "https://graphhopper.com/api/1/geocode?q=berlin&locale=de&key=api_key"

Responses

The results

Headers
X-RateLimit-Limitinteger

Your current daily credit limit.

X-RateLimit-Remaininginteger

Your remaining credits until the reset. This value is measured before the current request's cost is deducted. Subtract X-RateLimit-Credits to get the balance after the request.

X-RateLimit-Resetinteger

The number of seconds that you have to wait before a reset of the credit count is done.

X-RateLimit-Creditsinteger

The credit costs for this request. Note it could be a decimal and even negative number, e.g. when an async request failed.

Bodyapplication/json
hitsArray of objects(GeocodingLocation)

The results.

localestring

The language of the names in hits. default means that each name is in the local language.

Response
{ "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" }