Search by City Endpoint

On this page, we'll dive into the city search endpoint you can use to find postal codes for a specific city.


GET/v1/code/city

Search Codes by City

This endpoint returns the postal codes for a specified city, optionally filtered by state, in the order they were added. total is the number of postal codes of the city; when has_more is true, request the next page.

Required attributes

  • Name
    city
    Type
    string
    Description

    City name. Example: Anchorage

  • Name
    country
    Type
    string
    Description

    Two letter country code. Example: us

Optional attributes

  • Name
    state_name
    Type
    string
    Description

    State or province name to filter results. Example: Alaska

  • Name
    limit
    Type
    integer
    Description

    Postal codes per page, at most 10000 (a larger limit reads as 10000). If omitted, a page holds 10000 postal codes, which can count as many requests (1 request per 10 codes). Example: 10

  • Name
    page
    Type
    integer
    Description

    The page of the results, from 1. Default: 1.

Request

GET
/v1/code/city
curl -G "https://api.zipcodestack.com/v1/code/city?city=Anchorage&state_name=Alaska&country=us" \
    -H "apikey: YOUR-API-KEY"

Full Response

{
    "query": {
        "city": "Anchorage",
        "state": "Alaska",
        "country": "us"
    },
    "results": [
        "99501",
        "99502",
        "99503",
        "99504",
        "99505"
    ],
    "total": 5,
    "page": 1,
    "limit": 10000,
    "has_more": false
}