A Perl interface to the US Postal Service Web Tool

brian_d_foy on 2006-09-16T09:16:00

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. :)


Namespace?

Alias on 2006-09-16T11:25:33

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? :)

Re:Namespace?

brian_d_foy on 2006-09-16T17:09:35

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.

Re:Namespace?

DAxelrod on 2006-09-16T18:56:48

What about Business::US::USPS::WebTools?

Re:Namespace?

KM on 2006-09-17T00:05:26

Mail::Snail::Address or Mail::Snail::USPS could have been fun if Business::UPS and Business::FedEx didn't already exist.