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.
Checking API status...
/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
Returns a JSON array of objects, each with the following properties:
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!
https://api.api-ninjas.com/v1/postalcode?postal_code=K1A0B1Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
1
2
3
4
5
6
7
8
9
10
11
[
{
"city": "Ottawa",
"province": "ON",
"postal_code": "K1A 0B1",
"area_code": "613",
"timezone": "America/Toronto",
"lat": "45.4168",
"lon": "-75.7002"
}
]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.