Search code examples
apiusps

List of countries for USPS API


I'm going to use the USPS API for international shipping rates, but the list they provide is nearly 500 countries long. The listings include:

Fernando Po (Equatorial Guinea)
Hashemite Kingdom (Jordan) 
Muscat (Oman)
Nauru
Negri Sembilan (Malaysia)

And they all work as listed to provide postal rates.

But the list seems REALLY long.

I wondered if anyone had any suggestions about a shorter list?


Solution

  • I actually once went through that "list" (those tons of pages) manually, removed duplicates, renamed references, etc. and correlated them with ISO codes for a shipping cache Java application I wrote recently. I never finished it; I ended up not using it in the end.

    I found a much easier way to get their list was to start from the other end: just steal it from USPS itself. Go to their international rate calculator and view the source for the select box. A couple regular expressions should then have you on your way. It may not be completely up-to-date, I wouldn't be surprised if another department or different people maintained the two lists, but it should be pretty close.