Save over 30% when you subscribe to an annual subscription plan!

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_code  optional

    The 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.

  • city  optional premium only

    Full name of the city to search (case-sensitive).

  • province  optional premium only

    2-letter abbreviation of the province (e.g., ON, BC, QC).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

Returns a JSON array of objects, each with the following properties:

  • city

    The city name associated with the postal code.

  • province

    The 2-letter province abbreviation (e.g., ON, BC, QC).

  • postal_code

    The postal code in normalized format (A1A 1A1).

  • area_code

    The area code associated with the postal code.

  • timezone

    The timezone for the location (e.g., America/Toronto).

  • lat

    The latitude coordinate of the postal code location.

  • lon

    The longitude coordinate of the postal code location.

Sample Request Live Demo!

postal_code
https://api.api-ninjas.com/v1/postalcode?postal_code=K1A0B1

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
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.