Geocoding

Reverse geocoding

Turn a latitude/longitude into the address or place at that point.

Signed in? Open this endpoint in the dashboard playground, which uses your organization automatically. Signed out, use Try in Playground below with your API key.

GET
/geocode/reverse

Authorization

queryapiKey<token>

Your API key from the dashboard, sent as ?apiKey=<key>.

Query Parameters

lat*number

Latitude (-90 to 90).

Range-90 <= value <= 90
lon*number

Longitude (-180 to 180).

Range-180 <= value <= 180
limit?integer

Maximum number of results, 1-100 (default 1). Deviation (approximated): the result list is short regardless; see the operation description.

Range1 <= value <= 100
Default1
type?string

Requested result type. Omitted: building-level lookup (Canonical Addresses within 75 m, then Nominatim). street queries Nominatim at street zoom; country, state, city, postcode return the address found at the point reduced to that level (empty result if the level is missing); amenity queries Nominatim POI and address layers and returns a result only if it is an amenity. Canonical Addresses are not used when type is set. Deviation (unsupported): locality and building are rejected with 400.

Value in"country""state""city""postcode""street""amenity"
countrycodes?array<>

Keep only results in these ISO 3166-1 alpha-2 countries (case-insensitive, at most 10). Repeat the parameter or comma-separate values. Applied after lookup, so it can empty the result list. Deviation (approximated): any two-letter code is accepted; only us and ca have data.

Itemsitems <= 10
lang?string

Result language, forwarded to Nominatim as accept-language. Omitted: local names. Deviation (approximated): no default of en; Canonical Address results are not translated.

Value in"ab""aa""af""ak""sq""am""ar""an""hy""as""av""ae""ay""az""bm""ba""eu""be""bn""bh""bi""bs""br""bg""my""ca""ch""ce""ny""zh""cv""kw""co""cr""hr""cs""da""dv""nl""en""eo""et""ee""fo""fj""fi""fr""ff""gl""ka""de""el""gn""gu""ht""ha""he""hz""hi""ho""hu""ia""id""ie""ga""ig""ik""io""is""it""iu""ja""jv""kl""kn""kr""ks""kk""km""ki""rw""ky""kv""kg""ko""ku""kj""la""lb""lg""li""ln""lo""lt""lu""lv""gv""mk""mg""ms""ml""mt""mi""mr""mh""mn""na""nv""nb""nd""ne""ng""nn""no""ii""nr""oc""oj""cu""om""or""os""pa""pi""fa""pl""ps""pt""qu""rm""rn""ro""ru""sa""sc""sd""se""sm""sg""sr""gd""sn""si""sk""sl""so""st""es""su""sw""ss""sv""ta""te""tg""th""ti""bo""tk""tl""tn""to""tr""ts""tt""tw""ty""ug""uk""ur""uz""ve""vi""vo""wa""cy""wo""fy""xh""yi""yo""za"
format?string

Response format.

Default"geojson"
Value in"json""geojson""xml"

Response Body

Results sorted by distance; empty when nothing is found. Header X-Geo-Stage names the first result's stage.

  1. response

GeoJSON FeatureCollection (format=geojson, application/geo+json). features is empty when nothing is found.

type*unknown
features*array<>
query*

Echo of the request coordinates.

Example Request
curl -X GET 'https://api.data.graphitelab.ai/v1/geocode/reverse?lat=38.8977&lon=-77.0365&limit=2&type=street&countrycodes=us&lang=en&format=json'
Example Response
{  "results": [    {      "name": "White House",      "country": "United States",      "country_code": "us",      "state": "District of Columbia",      "state_code": "DC",      "city": "Washington",      "postcode": "20500",      "street": "Pennsylvania Avenue Northwest",      "housenumber": "1600",      "lon": -77.0365525,      "lat": 38.8976387,      "formatted": "White House, 1600 Pennsylvania Avenue Northwest, Washington, DC 20500, United States",      "address_line1": "1600 Pennsylvania Avenue Northwest",      "address_line2": "Washington, DC 20500, United States",      "result_type": "amenity",      "datasource": {        "sourcename": "openstreetmap",        "attribution": "© OpenStreetMap contributors",        "license": "Open Database License",        "url": "https://www.openstreetmap.org/copyright"      },      "rank": {        "confidence": 1,        "confidence_city_level": 1,        "confidence_street_level": 1,        "confidence_building_level": 1,        "match_type": "match_by_city_or_disrict",        "importance": 0.00000999999999995449      },      "place_id": "gp:osm:r19761182",      "distance": 8.2,      "bbox": {        "lon1": -77.0368541,        "lat1": 38.8974904,        "lon2": -77.0362509,        "lat2": 38.8977959      }    }  ],  "query": {    "lat": 38.8977,    "lon": -77.0365  }}

GET /v1/geocode/reverse returns the address or place nearest a coordinate. Use it to label a map click, a GPS fix or a stored point. Without type you get a building-level answer; with type you can ask for the street, city, state, postcode, country or an amenity instead.

How it works

Everything is answered from the service's own Engines, never from a third party.

  1. Canonical Addresses (PostGIS). Without type, the gateway looks up the nearest Canonical Address in the Address Point layer (NAD for the US, StatCan NAR for Canada, Overture). Any within 75 m count as building results. The query reads at most 30 candidates.
  2. Nominatim (OSM, TIGER). If fewer than limit results exist, the gateway asks Nominatim for a reverse lookup at building zoom (street zoom for type=street). A building already returned by step 1 is not repeated.
  3. Sort and filter. Results are sorted by distance, then countrycodes is applied, then the list is cut to limit.

With type set, only Nominatim answers. The X-Geo-Stage response header names the stage of the first result (canonical, an Engine stage, or none).

Quick start

curl -s "https://api.data.graphitelab.ai/v1/geocode/reverse?lat=38.8977&lon=-77.0365&apiKey=$GRAPHITE_API_KEY"
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "White House",
        "country_code": "us",
        "state_code": "DC",
        "city": "Washington",
        "postcode": "20500",
        "street": "Pennsylvania Avenue Northwest",
        "housenumber": "1600",
        "formatted": "White House, 1600 Pennsylvania Avenue Northwest, Washington, DC 20500, United States",
        "result_type": "amenity",
        "datasource": {
          "sourcename": "openstreetmap",
          "attribution": "© OpenStreetMap contributors",
          "license": "Open Database License",
          "url": "https://www.openstreetmap.org/copyright"
        },
        "rank": { "confidence": 1, "match_type": "match_by_city_or_disrict" },
        "place_id": "gp:osm:r19761182",
        "distance": 8.2
      },
      "geometry": { "type": "Point", "coordinates": [-77.0365525, 38.8976387] }
    }
  ],
  "query": { "lat": 38.8977, "lon": -77.0365 }
}

Parameters

NameTypeRequiredWhat it does
latnumberyesLatitude, -90 to 90.
lonnumberyesLongitude, -180 to 180.
limitintegernoMaximum results, 1 to 100 (default 1).
typestringnoOne of country, state, city, postcode, street, amenity. Omitted means building-level lookup. street queries Nominatim at street zoom. country, state, city and postcode return the address found at the point reduced to that level (empty if the level is missing). amenity returns a result only if the point resolves to an amenity. Canonical Addresses are not used when type is set.
countrycodesarray of stringsnoKeep only results in these ISO 3166-1 alpha-2 countries (case-insensitive, at most 10). Repeat the parameter or comma-separate values. Applied after lookup, so it can empty the list.
langstringnoISO 639-1 result language, forwarded to Nominatim as accept-language. Omitted means local names.
formatstringnojson, geojson (default) or xml.

Full parameter reference

Response

The default geojson format is a FeatureCollection sorted by distance; format=json returns the same properties under results. An uncovered point returns an empty list, not an error.

FieldMeaning
place_idTyped ID, gp:<kind>:<key>. Here gp:osm:... for OSM objects and gp:addr:canonical:... for Canonical Addresses.
result_typebuilding for Canonical Addresses, otherwise what Nominatim found (amenity, street, city, ...) or the requested type.
distanceMeters from the query point to the result.
datasourceWhere the result came from. OSM results carry "© OpenStreetMap contributors". Address Point results list their sources and each licence's attribution.
datasource.sources[]Extra: present when several Address Point sources agree on the same address.
rankGeoapify-shaped confidence fields filled by the service's own scoring.
bboxBounding box of the result, in properties and at feature level.

Differences from Geoapify

  • approximated: at most one Nominatim result plus the Canonical Addresses within 75 m are returned, so lists are short (usually 1 to 2) even with a large limit.

  • approximated (limit): accepted up to 100, but few candidates exist per point.

  • approximated (countrycodes): a post-filter on results. Any two-letter code is accepted, but only us and ca have data.

  • approximated (lang): not defaulted to en. Canonical Address results ignore lang.

  • unsupported: type=locality and type=building are rejected with 400. To get a building, omit type.

  • empty: only a subset of Geoapify's place fields is populated.

  • extra: datasource.sources[] when several Address Point sources agree, and the X-Geo-Stage response header.

US and Canada notes

  • Coverage is the United States and Canada only. A point elsewhere returns an empty list.

  • Building-level answers come from NAD (US), StatCan NAR (Canada) and Overture; OSM and TIGER fill the rest through Nominatim.

  • Canadian postcodes come back in full postal-code form, for example K1P 5M7.

  • Address Point street casing is echoed from the source, so you can see values like PENNSYLVANIA Avenue Northwest.

More examples

Canadian point, answered with an OSM amenity result.

curl -s "https://api.data.graphitelab.ai/v1/geocode/reverse?lat=45.4215&lon=-75.6972&apiKey=$GRAPHITE_API_KEY"

Errors and limits

StatusMeaning
400Invalid or missing parameters, including type=locality or type=building.
401Missing or invalid API key.
500Unexpected gateway error, including a Nominatim call that exceeds its 8 s timeout.
503Nominatim answered with an error status.

Limits: limit is 1 to 100, countrycodes takes at most 10 codes, and Canonical Addresses count only within 75 m of the point.

Known issue: with type=city, state, postcode or country, the result keeps the building node's place_id, bbox and distance, and rank.match_type is match_by_city_or_disrict. Treat those fields as describing the nearest building, not the area. The gp:addr:canonical path was documented from the code and has not been hit live.

Try in Playground (signed in to your Graphite Lab organization). Signed out, use the paste-your-key widget on the reference page.