Postal Code API
The Postal Code API looks up postal codes across more than 100 countries, returning the city, region and coordinates for a given code. Pass a two-letter country code alongside the postal code, or search in reverse by city or region.
The API covers 117 countries. A further 70 countries and territories operate no postal code system at all, and return has_postal_codes: false.
Popular countries: United Kingdom, India, Australia, Singapore, Indonesia, Germany, Netherlands, Malaysia, France, Japan, South Korea.
If you're looking for US zip codes, use the Zip Code API instead.
From 4,188 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 298ms | 319ms | 350ms | 731ms | 1187ms |
Didn't find what you were looking for? Suggest an improvement
https://api.api-ninjas.com/v1/postalcode
Returns a list of postal code details matching the input parameters.
Formatting is flexible. Spaces, hyphens and country prefixes are normalized, so 1011AB and 1011 AB both resolve, as do L-4968 and 4968.
Parameters
At least one of postal_code, city or region must be set:
countryoptionalTwo-letter ISO 3166-1 alpha-2 country code (e.g., GB, DE, IN, JP). Defaults to
CAwhen omitted.postal_codeoptionalThe postal code to look up. Spaces, hyphens and country prefixes are normalized automatically, so both the local written form and the bare code will resolve.
cityoptional Premium onlyFull name of the city or place to search (case-sensitive).
regionoptional Premium onlyName or code of the first-level region, such as a state, province or county (e.g., England, Bayern, ON).
provinceis accepted as an alias.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.
countryTwo-letter ISO country code for the result.
postal_codeThe postal code in its normalized local form.
cityThe city or place name associated with the postal code.
regionFirst-level region: state, province or county (e.g., England, Bayern).
region_codePremium onlyCode for the first-level region, where the country publishes one.
countyPremium onlySecond-level region: county, district or municipality.
county_codePremium onlyCode for the second-level region, where the country publishes one.
latPremium onlyThe latitude coordinate of the postal code location.
lonPremium onlyThe longitude coordinate of the postal code location.
timezoneThe IANA timezone for the location (e.g., Europe/London).
area_codeThe telephone area code for the location. Available for Canada only; for United States ZIP codes, use the Zip Code API, which returns
area_codesfor every US ZIP. Telephone area codes follow exchange boundaries rather than postal ones, so no equivalent mapping exists for other countries.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/postalcode?country=GB&postal_code=SW1A1AAHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/postalcode?country=GB&postal_code=SW1A1AA" \
-H "X-Api-Key: YOUR_API_KEY"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.
Frequently Asked Questions
Can I use the Postal Code API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Postal Code API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Postal Code API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Postal Code API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.Which countries does the Postal Code API cover?
The API covers over 100 countries. Pass a two-letter ISO 3166-1 country code to thecountryparameter along with apostal_code. Coverage varies by country, and we publish a per-country manifest showing the exact number of codes, the data source, and whether coverage is complete or partial, so you can check before you build. For US ZIP codes, use the Zip Code API.How do I look up a postal code?
Pass thecountryandpostal_codeparameters, for examplecountry=GB&postal_code=SW1A1AA. Formatting is flexible: spaces, hyphens and country prefixes are normalized, so1011ABand1011 ABboth resolve, as doL-4968and4968for Luxembourg. Review possible error codes if a lookup returns no match.What does the response include for each postal code?
Each object includescountry, the normalizedpostal_code,city,region, and the IANAtimezone. Paid plans additionally returnregion_code,county,county_code,latandlon. Thearea_codefield is available for Canada only; for US ZIP codes use the Zip Code API. To turn coordinates into a full address, pair this with the Geocoding API.Can I search by city or region instead of by code?
Yes. Supply thecityorregionparameter instead of a postal code to find every code in that area. These are premium-only inputs available on the paid plans listed on our pricing page.What happens for countries that do not use postal codes?
Around 68 countries and territories, including the United Arab Emirates, Hong Kong, Macau, Qatar and Panama, operate no postal code system at all. Rather than returning an empty result, the API responds withhas_postal_codes: falseand a short explanation, so your address forms can skip the field instead of failing validation.How is Canadian postal code data handled?
Canadian lookups remain the default when nocountryparameter is supplied, and theprovinceparameter is still accepted as an alias forregion, so existing integrations continue to work unchanged.