ZIP Code Lookup API provides the ZIP codes and postal codes to location data (city, state/province/region, country, latitude and longitude) and you can use it to find a postal code or ZIP code assigned anywhere in the world (to validate) or do ZIP code to city look-ups.
Seamlessly integrate our ZIP Code Lookup API in your applications to provide location-based services like setting up delivery routes, understanding the customers' demographics, running area-specific digital marketing campaigns, validating an address using the given postal code or ZIP code to improve data accuracy or address completion or correct errors or standardize formats, identifying a customer based on the provided ZIP/postal code to prevent frauds and many other use cases are there to efficiently use the ZIP Code Lookup API.
Verify that a ZIP code or a postal code is a valid one and exists where you’re looking for it to be.
Search & locate any ZIP code or postal code in the world with our fast ZIP Code Lookup API. You can restrain the search within a country as well.
ZIP Code Lookup API supports search for ZIP codes and postal codes assigned anywhere in the world.
Our ZIP Code Lookup API allows to lookup up to 100 postal codes and ZIP codes lookup in one go. Quickly handle bulk data accurately.
$ pip install requests
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
code | Yes | Array | - | Comma separated list of postal / zip codes. |
country | No | String | All countries | Country code in ISO 3166-1 alpha-2 format. If not provided, search results will be returned from all countries. |
You can pass up to 100 comma-separated postal/ZIP codes in the code URL parameter.
For a comprehensive view of the API response structure and detailed field descriptions, explore the interactive Response Table by clicking here.
HTTP Status | Reasons |
---|---|
400 | (1) A maximum of 100 postal/zip codes can be processed per request.
(2) 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 Lookup API:
You can perform the above operations in bulk for up to 100 postal codes or ZIP codes in one request to the ZIP Code Lookup API. Let's see some example use cases.
To validate the existence of one or more ZIP codes, you need to send a GET request passing your ZIP codes in the code URL parameter in your request. Here is a sample curl request to validate that 35005 and 10009 ZIP codes are valid and exist:
# Response { "results": [ { "code": "10009", "country_code": "DZ", "region": "Bouira", "city": "Ain Bessem Yahiaoui Larbi", "locality": "", "latitude": 36.3536, "longitude": 3.8415 }, { "code": "10009", "country_code": "GT", "region": "DEPTO DE SUCHITEPEQUEZ", "city": "SAN PABLO JOCOPILAS", "locality": "", "latitude": 14.5833, "longitude": -91.45 }, { "code": "10009", "country_code": "KR", "region": "Gyeonggi", "city": "Gimpo", "locality": "Gimpo-si", "latitude": 37.715855, "longitude": 126.60026 }, { "code": "10009", "country_code": "US", "region": "New York", "city": "New York", "locality": "", "latitude": 40.7262, "longitude": -73.9796 }, ... ... ... { "code": "35005", "country_code": "KW", "region": "Al-Asimah", "city": "Doha", "locality": "Doha (Block 5)", "latitude": 29.321714, "longitude": 47.82254 }, { "code": "35005", "country_code": "ES", "region": "Islas Canarias", "city": "Las Palmas de Gran Canaria", "locality": "Las Palmas de Gran Canaria", "latitude": 28.099379, "longitude": -15.413368 }, { "code": "35005", "country_code": "US", "region": "Alabama", "city": "Jefferson", "locality": "Adamsville (Adamsville)", "latitude": 33.592857, "longitude": -86.99402 } ] }curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup?code=35005,10009' --header 'X-apiKey: YOUR_API_KEY'
You can see that the 35005 and 10009 ZIP codes are assigned at many locations in the world. That's that way to verify that the ZIP codes are valid.
The above response is clearly not readable or say “usable” except checking the existence of ZIP codes The response from ZIP Code Lookup API returns city, region, country_code, latitude, and longitude along with the searched ZIP codes. You can further skim down the search to lookup within a country to make the response useful for address auto-completion, user verification or some other use cases.
To restrain the ZIP codes lookup within a country, you need to send a GET request with ZIP codes 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 (country, state/province/region, city, county, latitude and longitude) for 35005 and 10009 ZIP codes assigned in US country using our ZIP Code Lookup API as follows:
# Response { "results": [ { "code": "10009", "country_code": "US", "region": "New York", "city": "New York", "locality": "", "latitude": 40.7262, "longitude": -73.9796 }, ... { "code": "35005", "country_code": "US", "region": "Alabama", "city": "Jefferson", "locality": "Adamsville (Adamsville)", "latitude": 33.592857, "longitude": -86.99402 } ] }curl --location 'https://api.apifreaks.com/v1.0/zipcode/lookup?code=35005,10009&country=US' --header 'X-apiKey: YOUR_API_KEY'
ZIP Code Lookup API can provide response in the JSON and XML formats. JSON is the default response format for ZIP Code Lookup 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: YOUR_API_KEY'
73045 ZIP code is assigned at Harrah, Oklahoma, US.
To use the ZIP Code Lookup API, 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.
For each successful request, 5 credits will be charged for ZIP Code Lookup.
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.