ZIP Code API is an accurate city-level location data service for ZIP codes and postal codes. You can use it to validate and find the primary location of ZIP codes and postal codes anywhere in the world.
ZIP Code API has a wide range of applications in location-based businesses. Some anticipated applications of our location by ZIP code lookup service are:
You can integrate our ZIP Code API into your products with ease. Code snippets are available for many programming languages in each example below. You can follow each example as per need.
Lookup ZIP codes and postal codes to location data and validate if they exist where you're looking for them to be.
Find ZIP codes location ( city, locality, state/province/region, country code in ISO 3166-2 letter format, latitude, and longitude) with our fast ZIP Code API.
ZIP Code API gives you access to a global database of ZIP codes and postal codes location. ZIP Code API supports all postal data service like:
ZIP Code API supports up to 100 postal codes and ZIP codes lookup in one go. You can handle the bulk data with speed and accuracy.
ZIP codes lookup response supports JSON and XML formats. While the default response format is JSON.
$ pip install requests
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
| country | No | String | All countries | Limits the code's search to within a specified country. Country must be provided in ISO 3166-1 alpha-2 format. |
| code | Yes | String | - | Single ZIP code to validate or look up. Example: code=10009 |
| format | No | String | json | Toggles response format to JSON or XML. Value must be 'json' or 'xml'. Response format is JSON by default. Set 'format' param to 'xml' to get XML response. |
$ pip install requests
A maximum of 100 ZIP codes or postal codes can be included in the request body for a bulk lookup request.
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
| format | No | String | json | Toggles response format to JSON or XML. Value must be 'json' or 'xml'. Response format is JSON by default. Set 'format' param to 'xml' to get XML response. |
For bulk ZIP code requests, include a codes array in JSON format (e.g., ‘10003‘, ‘12001‘, ‘35005‘) with up to 100 ZIP codes per request. Optionally, you can add a country parameter with the ISO 3166-1 alpha-2 code (e.g., ‘US‘, ‘PK‘) to filter results by country.
{
"codes": [
"54270",
"50000"
],
"country": "PK"
}For a comprehensive view of the API response structure and detailed field descriptions, explore the interactive Response Table. For ZIP Code Single Lookup API click here and for ZIP Code Bulk API click here.
| HTTP Status | Reasons |
|---|---|
| 400 | Only ISO 3166-1 alpha-2 codes country codes are supported. |
| 404 | None of the provided postal/zip codes were found in our database. |
Here are the two most common uses of using our ZIP Code API:
To validate the existence ZIP code, send a GET request including your ZIP code in the code URL parameter. Here is a sample cURL request to validate that the 10009 ZIP code exists:
# Response { "results": [ { "code": "10009", "country_code": "TW", "region": "Taipei City", "region_code": "TPE", "city": "Taipei City", "locality": "Zhongzheng District", "latitude": 25.04214, "longitude": 121.51987 }, { "code": "10009", "country_code": "IQ", "region": "Baghdad", "region_code": "BG", "city": "Baghdad", "locality": "Al Hurriya", "latitude": 33.3229, "longitude": 44.397804 }, { "code": "10009", "country_code": "GT", "region": "DEPTO DE SUCHITEPEQUEZ", "region_code": null, "city": "SAN PABLO JOCOPILAS", "locality": "", "latitude": 14.5833, "longitude": -91.45 }, { "code": "10009", "country_code": "KR", "region": "경기도", "region_code": "41", "city": "통진읍", "locality": "", "latitude": 37.7158, "longitude": 126.5952 }, { "code": "10009", "country_code": "US", "region": "New York", "region_code": "NY", "city": "New York County", "locality": "Manhattan", "latitude": 40.725872, "longitude": -73.98085 }, { "code": "10009", "country_code": "UA", "region": "Zhytomyr Oblast", "region_code": "18", "city": "Zhytomyr", "locality": "Koroliovskyi Raion", "latitude": 50.2649, "longitude": 28.6767 }, { "code": "10009", "country_code": "DZ", "region": "Bouira", "region_code": "10", "city": "Bouïra District", "locality": "Said Abid", "latitude": 36.3536, "longitude": 3.8415 } ] }curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup?code=10009' --header 'X-apiKey: API-KEY'
Response from ZIP Code API confirms that 10009 ZIP code is valid and exists in 9 countries of the world.
To restrain the ZIP code lookup within a country, you need to send a GET request with ZIP code in the code URL parameter and country is ISO 3166-1 alpha-2 format in country URL parameter. Here is a cURL request to get the location for 35005 ZIP code assigned in US country using our ZIP Code API as follows:
# Response { { "results": [ { "code": "35005", "country_code": "US", "region": "Alabama", "region_code": "AL", "city": "Jefferson County", "locality": "Adamsville", "latitude": 33.59224, "longitude": -86.947845 } ] } }curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup?code=35005&country=US' --header 'X-apiKey: API-KEY'
ZIP Code API's bulk lookup endpoint allows to search up to 100 ZIP codes and postal codes in one go.
To fetch detailed information or validate multiple ZIP codes in one request, simply send a POST request to the Bulk ZIP Code Lookup endpoint. Include your ZIP codes inside the codes array in the JSON body, and optionally pass the country parameter (ISO 3166-1 alpha-2) if you want to limit the results to a specific country.
Here is a cURL request to search 10003, 12001 and 35005 ZIP codes in US:
# Response { "results": [ { "code": "10003", "country_code": "US", "region": "New York", "region_code": "NY", "city": "New York County", "locality": "Manhattan", "latitude": 40.73134, "longitude": -73.98873 }, { "code": "35005", "country_code": "US", "region": "Alabama", "region_code": "AL", "city": "Jefferson County", "locality": "Adamsville", "latitude": 33.59224, "longitude": -86.947845 } ] }curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup' --header 'X-apiKey: API-KEY' --header 'Content-Type: application/json' --data '{ "codes": ["35005", "10003", "12001"], "country":"US" }'
Since 12001 ZIP code doesn't exist in US, it isn't included in the response.
ZIP Code API can provide response in the JSON and XML formats. JSON is the default response format for ZIP Code API. You can get the response in XML format by passing the URL parameter format=xml in the above requests.
Let's lookup 73045 ZIP code in US and get response in XML format.
# Response <CodeSearch> <results> <code_search> <code>73045</code> <country_code>US</country_code> <region>Oklahoma</region> <city>Harrah</city> <locality /> <latitude>35.4833</latitude> <longitude>-97.1734</longitude> </code_search> </results> </CodeSearch>curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup?format=xml&code=73045&country=US' --header 'X-apiKey: API-KEY'
73045 ZIP code is assigned at Harrah, Oklahoma, US.
To use the ZIP Code APIs, API credits are required. Charges apply only for successful queries, defined by a 2xx status code. If a request results in a 4xx or 5xx status code, no credits will be deducted, and any credits already charged will be refunded. If an error occurs while processing the postal/zip code, credits will be refunded for that postal/zip code, and you will only be charged for successful lookups of postal/zip codes.
Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.