Postal Code API
The Postal Code API enables you to look up detailed information for postal codes in Canada. You can input postal codes directly, or search for postal codes using city and province parameters.
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
/v1/postalcode GET
https://api.api-ninjas.com/v1/postalcode
Returns a list of postal code details matching the input parameters.
Parameters
At least one of the following parameters must be set:
postal_codeoptionalThe postal code to look up. Accepts Canadian postal codes in 6 characters (A1A1A1) or 7 characters with a space (A1A 1A1). The space will be automatically normalized if not provided.
cityoptional premium onlyFull name of the city to search (case-sensitive).
provinceoptional premium only2-letter abbreviation of the province (e.g., ON, BC, QC).
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.
cityThe city name associated with the postal code.
provinceThe 2-letter province abbreviation (e.g., ON, BC, QC).
postal_codeThe postal code in normalized format (A1A 1A1).
area_codeThe area code associated with the postal code.
timezoneThe timezone for the location (e.g., America/Toronto).
latThe latitude coordinate of the postal code location.
lonThe longitude coordinate of the postal code location.
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?postal_code=K1A0B1Headers
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?postal_code=K1A0B1" \
-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 country's postal codes does the Postal Code API cover?
The Postal Code API covers Canadian postal codes only, returning thecity,province,area_code,timezone, andlat/loncoordinates for a given code. If you need US ZIP codes instead, use the Zip Code API.How do I look up a specific Canadian postal code?
Pass the postal code to thepostal_codeparameter, accepting either the 6-character form (A1A1A1) or the 7-character form with a space (A1A 1A1); the space is normalized automatically if omitted. Review possible error codes if a lookup returns no match.Can I search for postal codes by city and province instead of by code?
Yes, you can supply thecity(full name, case-sensitive) andprovince(2-letter abbreviation such as ON, BC, or QC) parameters instead of a postal code, but these are premium-only inputs available on paid plans listed on our pricing page.What location data does the response include for each postal code?
Each object in the JSON array includescity,province, normalizedpostal_code,area_code,timezone(e.g., America/Toronto), and thelatandloncoordinates. To convert those coordinates into a full address or vice versa, pair this with the Geocoding API.