Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Saturday September 16, 2006
03:54 AM

A Perl interface to the US Postal Service Web Tools

[ #31015 ]

I've written Business-USPS-WebTools to interact with the US Postal Service's Web Tools. This isn't screen scraping; it's a real web service officially offered by the USPS. SO far I've only done the Address Information services: Address Standardization, Zip Code Lookup, and City/State Lookup. I didn't use any of the XML modules or anything other yucky things. The requests and responses are very small, and the other side doesn't understand real XML anyway.

The kicker is that you need an account and it's a rather dodgy system for getting one. The USPS will initially give you a developer user id and a password, but it only works on their test system and only for very specific queries (all of which are test cases for these modules). After that, you have to somehow get ahold of the USPS Internet Customer Care Center to get the real server details. I'm not going to violate their terms of service by posting those details here (and they haven't made it into the module yet because I want to ensure it's doing everything right first).

You may notice that my implementation diverges a bit from the USPS docs. I went with what their servers actually did, not the cut-n-paste hack job they posted for developers. It took me about a half hour to convince myself that I was reading the right sections of the docs because they looked a lot like the previous sections. It turns out they were the previous sections doing overtime.

It's just hit PAUSE, so it might take a bit to get to CPAN. They are alpha right now, and there are some interface things I need to fix, but its a start. Eventually, i'll put this together with the mailing label modules to print nice, machine readable addresses for The Perl Review. :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Normally I'd be pretty relaxed about not using a national namespace, since a lot of US companies have global reach, but in this instance, I think this is probably one we can safely say belongs in Business::US::... Business::US::PS perhaps? :)
    • Well, USPS has to stay together. I've thought about "USPostalService" and some other things too. The Postal Service actually has requirements about how the name has to appear, although I'm not highly motivated to comply with them (nor motivated not to comply, either).

      I'm not really attached to the namespace, either. Just saying "Business::USPS::WebTools" doesn't say much unless you know what USPS is. Right now I just want to get the software working, so I went around that little speed-bump.
      • What about Business::US::USPS::WebTools?
      • Mail::Snail::Address or Mail::Snail::USPS could have been fun if Business::UPS and Business::FedEx didn't already exist.