Reverse Lookup Endpoint

Turns a latitude and longitude into the postal codes nearest to it, closest first.

Use it to fill in a postal code from a phone’s GPS position, to assign orders or leads to a delivery area, or to show which postal code a map click falls into.


GET/v1/reverse

Reverse Lookup

Returns the postal codes within radius of the point, ordered by distance, with the full location data of each.

Required attributes

  • Name
    latitude
    Type
    number
    Description

    Latitude between -90 and 90. Example: 48.2080

  • Name
    longitude
    Type
    number
    Description

    Longitude between -180 and 180. Example: 16.3710

Optional attributes

  • Name
    country
    Type
    string
    Description

    Only return codes of this two-letter country. Useful near borders.

  • Name
    radius
    Type
    number
    Description

    Search radius in unit. Default 10 km, at most 50 km (31 miles).

  • Name
    unit
    Type
    string
    Description

    km (default), mi or miles. Applies to radius and to the returned distance.

  • Name
    limit
    Type
    integer
    Description

    How many codes to return, 1 to 100. Default 10.

Response

results holds the nearest codes with the same fields as /v1/search plus distance from your point, rounded to two decimals. It is an empty list when no code lies within the radius, for example in the open sea; increase radius in rural areas.

Request

GET
/v1/reverse
curl -G https://api.zipcodestack.com/v1/reverse \
    -d latitude=48.2080 \
    -d longitude=16.3710 \
    -d limit=2 \
    -H "apikey: YOUR-API-KEY"

Response

{
    "query": {
        "latitude": 48.208,
        "longitude": 16.371,
        "country": null,
        "radius": 10,
        "unit": "km",
        "limit": 2
    },
    "results": [
        {
            "distance": 0.05,
            "postal_code": "1010",
            "country_code": "AT",
            "latitude": 48.2077,
            "longitude": 16.3705,
            "city": "Wien, Innere Stadt",
            "state": "Wien",
            "city_en": "Wien, Innere Stadt",
            "state_en": "Wien",
            "state_code": "09",
            "province": "Wien Stadt",
            "province_code": "900",
            "community": "Wien, Innere Stadt",
            "community_code": "90101",
            "accuracy": 4
        },
        {
            "distance": 2.21,
            "postal_code": "1020",
            "country_code": "AT",
            "latitude": 48.2167,
            "longitude": 16.3982,
            "city": "Wien, Leopoldstadt",
            "state": "Wien",
            "city_en": "Wien, Leopoldstadt",
            "state_en": "Wien",
            "state_code": "09",
            "province": "Wien Stadt",
            "province_code": "900",
            "community": "Wien, Leopoldstadt",
            "community_code": "90201",
            "accuracy": 4
        }
    ]
}