It is possible to do this properly, e. G., DHL and UPS do a somewhat okay job of it but isn't easy.
Put the zip code first
171–180 of 330 posts
Re: Put the zip code first
#172Earlier quoted context omitted.
USPS doesn't care; each ZIP code has a single preferred city name and a list of acceptable alternate city names to account for cases in which a ZIP code spans multiple cities. However, USPS's address validation will prefer to use the preferred city name for the ZIP regardless of whether the recipient actually lives within the boundaries of that city. That's because USPS has opted to organize addressing entirely aroun…
But addresses aren’t just for sending mail. Location also determines which municipal and state laws apply, so there are contexts where the distinction matters.
Re: Put the zip code first
#173Earlier quoted context omitted.
> A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state. These are reasons you cannot deduce the Zip from the city, not the opposite. A ZIP+4 actually encodes all other information for a US address.
ZIP+4? I think that's literally enough digits to give every house in the US (about 150,000,000 apparently) its own identifier.
Re: Put the zip code first
#174Earlier quoted context omitted.
This 1000 times. I’ve tried implementing what OP has mentioned, and quickly learned it isn’t possible. A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state. So, to be safe, you have to enter city, state, and zip.
I don’t understand either of these arguments. They both appear to reinforce the point made in the article. At worst a zip code contains multiple cities? Voila the city box becomes a dropdown. It’s 2025. JavaScript.
Re: Put the zip code first
#175Earlier quoted context omitted.
This 1000 times. I’ve tried implementing what OP has mentioned, and quickly learned it isn’t possible. A city can also exist in multiple zip codes. And there can be multiple cities with the same name in the same state. So, to be safe, you have to enter city, state, and zip.
There are enough ZIP+4 codes for about a billion addresses. Many addresses I've lived at in the US have had a unique ZIP+4 code.
Re: Put the zip code first
#176> From those 5 characters you can determine the city, the state, and the country False. Many zip codes include more than one city, and some even cross multiple states. And you can't always tell the difference between codes from different countries. Now you're not just instantly filling the rest of the form, you're implementing fancy multi-country filtering logic, editable drop downs, etc. Given the obvious incompeten…
Re: Put the zip code first
#177Earlier quoted context omitted.
USPS doesn't care; each ZIP code has a single preferred city name and a list of acceptable alternate city names to account for cases in which a ZIP code spans multiple cities. However, USPS's address validation will prefer to use the preferred city name for the ZIP regardless of whether the recipient actually lives within the boundaries of that city. That's because USPS has opted to organize addressing entirely aroun…
But addresses aren’t just for sending mail. Location also determines which municipal and state laws apply, so there are contexts where the distinction matters.
Re: Put the zip code first
#178You’d absolutely have to determine that you’re in the US before asking for zip code.
Re: Put the zip code first
#179> From those 5 characters you can determine the city, the state, and the country False. Many zip codes include more than one city, and some even cross multiple states. And you can't always tell the difference between codes from different countries. Now you're not just instantly filling the rest of the form, you're implementing fancy multi-country filtering logic, editable drop downs, etc. Given the obvious incompeten…
USPS doesn't care; each ZIP code has a single preferred city name and a list of acceptable alternate city names to account for cases in which a ZIP code spans multiple cities. However, USPS's address validation will prefer to use the preferred city name for the ZIP regardless of whether the recipient actually lives within the boundaries of that city. That's because USPS has opted to organize addressing entirely aroun…
What I want to know is: Why isn't this preferred city+state mapping dataset for zip codes publicly available from USPS? It would be like 40kb of data for the entire thing. Why is this not public domain from the US Government?
Edit: or is this what I'm looking for (the "Physical City", "Physical State" columns? https://postalpro.usps.com/ZIP_Locale_Detail
It's missing 00501 at least (which zippopotam has), and military zip codes (which zippopotam doesn't have). Military zip codes are included in this file: https://postalpro.usps.com/areadist_ZIP5
Also fun fact 88888 is for "Operation Santa" uspsoperationsanta.com, which zippopotam is missing, but appears in the areadist_ZIP5 file.