Search code examples
perlperl-modulezipcode

Is there a CPAN module listing U.S. ZIP codes and states?


Basically, I am looking for a module that can tell me:

  1. All the ZIP codes in a given state
  2. Whether a given ZIP code is in a given state
  3. The state to which a given ZIP code belongs

I would prefer this to be standalone, so I don't pull a whole bunch of dependencies.

I am basically asking this because I am about to generate a module using this file I found on the U.S. Census Bureau web site, and I don't want to waste time on it if something suitable already exists.

I am not going to look up city names by ZIP code, so I don't care that, e.g., the Tiger file thinks 14850 is just for Ithaca College, but then I also don't know if there are other problems with that file.

If you don't know of a suitable CPAN module, I would also appreciate naming suggestions for such a module, and better sources of data.

I have a feeling the USPS wants to charge for a proper list, and the U.S. Census Bureau is not interested:

In the past, the Census Bureau produced the 1990 Gazetteer ZIP Code file and a 1999 ZIP Code file. These files were produced as byproducts of Census Bureau internal operations. They were not developed as a formal product. However, the Census Bureau has made them available to the public "as is". There will be no updated versions of these files.


Solution

  • U.S. Postal Service does give access to an address information API. I am not sure how to respond to "What is the Web site address (URL) of the site that will be hosting the USPS Web Tools?" for the simple purpose of packaging a look up table, but I am mentioning it here in case someone else finds it useful.

    Depending on the user's goals, one of the labeling lists found in pe.usps.gov/text/LabelingLists/ might be suitable. It looks like I am going to use one of those tables as a first pass at reducing the number of cases to be examined.

    Finally, Twilio/Wigle.net Street Vector Data Set on Amazon AWS might provide all the detail you might ever need, but I have not checked to see if you can list ZIP codes by states.