Zip Code API

The Zip Code API enables you to look up detailed information for every ZIP Code in the United States. You can input ZIP Codes directly, or search for ZIP Codes using city and state parameters.

/v1/zipcode GET

https://api.api-ninjas.com/v1/zipcode

Returns a list of ZIP Code details matching the input parameters.


Parameters

At least one of the following parameters must be set:

  • zip  optional

    The ZIP Code to look up.

  • city  optional

    Full name of the city to search (case-sensitive).

  • state  optional

    2-letter abbreviation of the state (case-insensitive).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

city
state
https://api.api-ninjas.com/v1/zipcode?city=Portland&state=OR

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [ { "zip_code": "97201", "valid": true, "city": "Portland", "state": "OR", "county": "Multnomah County", "timezone": "America/Los_Angeles", "area_codes": [ "503", "971" ], "country": "US", "lat": "45.5074", "lon": "-122.6898" }, { "zip_code": "97202", "valid": true, "city": "Portland", "state": "OR", "county": "Multnomah County", "timezone": "America/Los_Angeles", "area_codes": [ "971" ], "country": "US", "lat": "45.4803", "lon": "-122.6451" } ]

Code Examples

1 2 3 4 5 6 7 8 9 10 11 import requests city = 'Portland' state = 'OR' api_url = 'https://api.api-ninjas.com/v1/zipcode?city={}&state={}'.format(city, state) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.