views:

1375

answers:

3

Are there any good webservices out there that provide good lookup information for Countries and States/Provinces?

If so what ones do you use?

+6  A: 

If you only need US information, the US Postal Service provides a set of web services it calls WebTools for this exact thing. http://www.usps.com/webtools/address.htm. You will need to register to be able to use them but once you're registered they are really simple to use. You just send an XML request over HTTP and the server sends an XML response back and you just have to unpack it.

Sample request:

http://SERVERNAME/ShippingAPITest.dll?API=Verify&amp;XML=&lt;AddressValidateRequest%20USERID="xxxxxxx"&gt;&lt;Address ID="0"><Address1></Address1><Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State><Zip5></Zip5><Zip4></Zip4></Address></AddressValidateRequest>

Sample response:

<?xml version="1.0"?>
<AddressValidateResponse>
     <Address ID="0">
         <Address2>6406 IVY LN</Address2>
         <City>GREENBELT</City>
         <State>MD</State>
         <Zip5>20770</Zip5>
         <Zip4>1441</Zip4>
     </Address>
</AddressValidateResponse>

Here's a link to the technical documentaion: http://www.usps.com/webtools/technical.htm

Owen
A: 

A good source of geographic data, including lookups and mapping data for the USA is the US Census Bureau's TIGER Data set. They no longer actively track Zip code data, but they do have a 1999 vintage file still available.

For countries, the ISO country code list is publicly available.

I'm not aware of resources for information outside the US.

Kyle Burton
+2  A: 

http://www.geonames.org/

That's the best one I've found. They let you download and host the web service yourself, which is also nice.