Check if Zip Code or postal code is real

13.3k views Asked by At

After some searching, I haven't been able to find a definite answer.

If I am given a zip code like 11111, it is technically a valid zip code but it doesn't exist. Is there a way to check this? The same goes for a postal code like a1a a1a (valid but not real).

2

There are 2 answers

0
Cody Caughlan On BEST ANSWER

For United States zipcodes:

You can purchase / download databases of zip codes, which you can use in your local app.

Google for

us zip code database

Here is one that you can use for free for non-commercial purposes (for commercial purposes you can purchase a cheap license):

http://www.unitedstateszipcodes.org/zip-code-database/

There are some providers which allow you to perform remote HTTP calls, search around

0
Robert Muil On

For any who stumble onto this and are using Python, this exists: https://github.com/Brobin/usps-api

It doesn't cover all the API functionality, but it makes the standard stuff much easier than constructing XML by hand.