Skip to Content
BuddyGeoDocs

Reverse geocoding

GET /v1/reverse turns a latitude and longitude into the nearest mapped address, with its components, its own coordinate and an explanation of the match.

Reverse geocoding answers the question "what is at this coordinate?". You send a point; BuddyGeo returns the nearest mapped feature, as a formatted address and as separate fields.

Request

curl "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871" \
  -H "X-API-Key: YOUR_API_KEY"
ParameterRequiredDescription
latYesLatitude in decimal degrees, -90 to 90
lonYesLongitude in decimal degrees, -180 to 180
langNoLanguage of the result as a BCP 47 tag. Default en. See Languages
detailNofull (default), street or locality: how precise the returned address should be

Latitude comes first wherever a pair is written out. See Coordinate order.

Response

{
  "request_id": "req_5d0c3f9a1b7e",
  "endpoint": "/v1/reverse",
  "status": 200,
  "outcome": "success",
  "latency_ms": 62,
  "credits_charged": 1,
  "credits_remaining": 38160,
  "query": { "lat": 43.6426, "lon": -79.3871 },
  "result": {
    "place_id": "toronto-cn-tower",
    "formatted": "290 Bremner Boulevard, Toronto, ON M5V 3L9, Canada",
    "components": {
      "name": "CN Tower",
      "house_number": "290",
      "street": "Bremner Boulevard",
      "neighbourhood": "Entertainment District",
      "locality": "Toronto",
      "region": "Ontario",
      "region_code": "ON",
      "postcode": "M5V 3L9",
      "country": "Canada",
      "country_code": "ca"
    },
    "location": { "lat": 43.642196, "lon": -79.386628 },
    "bounding_box": [43.641657, 43.642735, -79.387373, -79.385883],
    "match": {
      "level": "address",
      "detail": "Nearest mapped address to the submitted point, 59 m away.",
      "distance_m": 59,
      "osm_type": "way",
      "osm_id": 461829037,
      "category": "tourism",
      "type": "attraction"
    },
    "language": "en",
    "available_languages": ["en", "fr"]
  },
  "error": null,
  "attribution": "© OpenStreetMap contributors (ODbL)"
}

The envelope

FieldDescription
request_idIdentifier of this request, also sent as the X-Request-Id header. Search for it in Request logs or quote it to support
endpointThe endpoint that answered, here /v1/reverse
statusThe HTTP status of the response, repeated in the body
outcomesuccess, no_match, invalid, unauthorized, rate_limited, quota_exhausted or upstream_error
latency_msTime the service spent on the request
credits_charged1 for a successful lookup, 0 for everything else
credits_remainingAvailable credits of the workspace after this request, or null for unauthenticated public playground previews
queryThe parameters the service understood
resultThe matched feature, or null
errornull, or an object with code, message and next_step
attributionThe credit line to show with the result. See Attribution

The result

FieldDescription
result.formattedThe address on one line, formatted the way it is written locally
result.componentsThe same address as fields: name, house_number, street, neighbourhood, locality, county, region, region_code, postcode, country, country_code. Only country and country_code are always present
result.locationCoordinate of the returned feature, which is usually not the point you submitted
result.bounding_boxExtent of the feature as [south, north, west, east]
result.match.levelHow precise the match is: address, street, poi, neighbourhood, locality, region or country
result.match.detailOne sentence explaining what was matched and why
result.match.distance_mMetres between the submitted point and the returned feature
result.match.osm_type, osm_id, category, typeThe OpenStreetMap object behind the result
result.language, result.available_languagesLanguage of this result and the languages it could be returned in

Submitted point and returned point

A reverse lookup snaps to the nearest mapped feature. For the CN Tower example the submitted point is 43.6426, -79.3871 and the returned address sits at 43.642196, -79.386628, 59 metres away. Show both when it matters to your users, as the reverse playground does with two markers and a connector, and use match.distance_m to decide whether a result is close enough for your purpose.

Not every place has a house number

How much detail comes back depends on what is mapped near the point.

ExampleWhat comes back
CN Tower, TorontoA full street address with house number and postcode (match.level: "address")
IFC, Hong KongA complete address without a postcode, because Hong Kong does not use them. components.postcode is absent
Big Ben, LondonA named place without a house number (match.level: "poi")
Khumbu region, NepalNo street is mapped nearby, so the answer stops at the locality (match.level: "locality")
Open ocean, North AtlanticNothing is mapped near the point: result is null, outcome is no_match, zero credits

Treat every field of components except country and country_code as optional.

Ask for less detail

detail trims the answer when you do not want a house number:

curl "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871&detail=locality" \
  -H "X-API-Key: YOUR_API_KEY"
detailformatted for the CN Tower pointmatch.level
full290 Bremner Boulevard, Toronto, ON M5V 3L9, Canadaaddress
streetBremner Boulevard, Toronto, ON M5V 3L9, Canadastreet
localityToronto, Ontario, Canadalocality

detail never adds precision: a point that only matches a locality returns that locality at every level. Any other value is rejected with 400 invalid_query.

No match is not an error

A point in open water or far from anything mapped returns HTTP 200 with result: null:

curl "https://api.buddygeo.com/v1/reverse?lat=30&lon=-40" \
  -H "X-API-Key: YOUR_API_KEY"

outcome is no_match and credits_charged is 0. Check result for null before reading result.formatted.

Example locations

Try any of these example points directly in the reverse playground:

PlaceLatitudeLongitudeAnswer
CN Tower, Toronto43.6426-79.3871Address
Tokyo Tower, Tokyo35.6586139.7454Address
MASP, São Paulo-23.5614-46.6559Address
Big Ben, London51.5007-0.1246Address
Eiffel Tower, Paris48.85842.2945Address
Empire State Building, New York40.7484-73.9857Address
Sydney Opera House-33.8568151.2153Address
Brandenburg Gate, Berlin52.516313.3777Address
IFC, Hong Kong22.2855114.1588Address
Khumbu region, Nepal27.988186.925Address
Grand-Place, Brussels50.84674.3525Address
Ferry Building, San Francisco37.7955-122.3937Address
Zócalo, Mexico City19.4326-99.1332Address
Gateway of India, Mumbai18.92272.8347Address
V&A Waterfront, Cape Town-33.903618.4209Address
Burj Khalifa, Dubai25.197255.2744Address
KICC, Nairobi-1.288436.8233Address
Merlion Park, Singapore1.2868103.8545Address
Open ocean, North Atlantic30-40No match (0 credits)
Point Nemo, South Pacific-48.8767-123.3933No match (0 credits)

Open in the app

On this page