The USPS created the ZIP Code system, and they're the ones who maintain it. In fact, the whole system is designed to make their jobs a little easier by breaking the whole country down into bite-sized chunks. If all you need is a handful of domestic ZIP Codes, the easy answer is to go to the source. If you're looking for an API that produces ZIP Codes from addresses, there's a lot to choose from. So we could just grab a bunch of names and throw them at you like confetti, but that wouldn't be very helpful (unless you're having a party). So instead we've set up some parameters so that we can better point you in the direction of a provider that meets your needs. Here's some of the details you may want to consider:
Some providers, as mentioned above, can give you ZIP Codes for free. After all, the USPS is happy to give you the ZIP Codes you need to make their delivery job easier. But if you're looking to dump 50k, 100k, or more on a monthly, weekly, or—heaven forbid—daily basis, you'll have to go a different route. Most free services will restrict you to a one-at-a-time usage that keeps you from overloading their system. With larger quantities you're looking for a provider that is willing to process your data and return them in a timely manner.
We hate to break it to you, but that's the kind of thing a business would charge for.
Just like with geocoding and address validation, there's a pretty wide range on price for ZIP Codes. A lot of that is due to the fact that any bulk ZIP Code lookups you might be doing are going to be done with a provider that also performs validation and geocoding, and you're paying for a package deal. That's not to say it's bad, just that you're going to have to play with your price/speed/functions venn diagram for a little bit if you find you only want the ZIP Codes.
More on both speed and bonus functionalities down below.
When you say you're looking for a ZIP Code, that can mean a number of different things. Our first assumption might be that you're looking to finish off a specific mailing address with its associated ZIP Code. You'd add it yourself, but you can't be expected to know everything. Especially if "everything" includes knowing over 40,000 ZIP Codes.
Our second assumption is that you need to match a city/state combination (rather than a specific address) to a ZIP Code. Here's an easy example: Los Angeles, California, has, well, like, a lot of ZIP Codes. If you just want any Los Angeles ZIP Code, then they're pretty easy to come by. That kind of "horseshoes" accuracy can usually be grabbed with something as simple as a Google search.
However, if you're looking to complete a specific address as mentioned above, your best bet is to go with an address data provider. The USPS is the obvious example, but there's also commercial providers that can standardize the address and add the requisite ZIP Codes. Some even supplement this service with address validation and geocoding.
An important detail on accuracy: you're going to have a hard time with any address in an area where mail is only delivered to PO Boxes. The good news is that the USPS—and any commercial provider that references their data—has a list of all the ZIP Codes that are PO Box–only ZIP Codes. The bad news is the USPS doesn't keep a registry of physical addresses that they don't deliver to. So if you suspect that a physical address might only receive mail at a PO Box, you may want to search for just city/state level accuracy. Try to keep this in mind if a good number of your addresses come from these places.
Now let's talk about a few qualities critical for the die-hard, don't-mess-around ZIP Code hunters: API quality, speed & capacity, and extra functionality.
We are talking about APIs, right? Not just ZIP Codes and confetti? That's good, because we have some pretty extensive dissertations on the pros and cons of some APIs that would likely suit your needs. These lists are about geocoders and address validators respectively, but just about everyone on either list offers ZIP Codes as part of their package.
Again, what features you choose depends on what you need and how much you'll use the API. There are some really solid APIs out there, with restriction-free usage, stellar uptime, and quality data. The value of API real-time functionality cannot be overstated. But if you don't need any of that then there's no reason to pay for it.
Mind you, most of the providers we looked at offered a significant amount of free service, so they're worth checking out either way.
If you're really serious about getting your ZIP Codes, speed is likely the kicker. You need a lot of ZIP Codes, you need them fast, and likely you need them on a regular basis.
A good number of providers offer what you're looking for in all three categories, and finding a price that's right is easier than you might expect. And again, many of these providers also offer free options below a certain usage threshold.
There's a number of bells and whistles that can come as part of a package when you go looking for someone to provide you with ZIP Codes. And some of them may be things you need. A few examples:
We strongly recommend perusing our articles on geocode APIs and validation APIs, where we give breakdowns on some providers, discussing many of the same points mentioned here, as well as our article on how to find a good API. You can also take our ZIP Code API for a test run, if you feel so inclined.
In the end, finding the right provider is going to take two things: knowing what you want, and knowing what's out there. This article and the others linked here should take care of most of the "what's out there" part. The rest—well, that's up to you.