Webservice to get city names by specifying Zip codes

I need a reliable webserivce that gives the corresponding name of the city, passing the zip code. This web service should work at all times. This web service will also be used in production.

+8
c # web-services sharepoint sharepoint-2010
source share
6 answers

I found several ways to do this using the web APIs. I think the US Postal Service will be the most accurate, since Zip codes are their business, but Ziptastic looks a lot simpler.

US HTTP / XML API Usage

According to this page on the U.S. Postal Service website, which documents its XML-based web API , in particular section 4.0 (page 22) of this PDF , they have a URL where you can send an XML request containing A 5-digit zip code and they will respond with an XML document containing the appropriate city and state.

According to their documentation, here is what you would send:

http://SERVERNAME/ShippingAPITest.dll?API=CityStateLookup&XML=<CityStateLookupRequest%20USERID="xxxxxxx"><ZipCode ID= "0"><Zip5>90210</Zip5></ZipCode></CityStateLookupRequest> 

And here is what you get back:

 <?xml version="1.0"?> <CityStateLookupResponse> <ZipCode ID="0"> <Zip5>90210</Zip5> <City>BEVERLY HILLS</City> <State>CA</State> </ZipCode> </CityStateLookupResponse> 

USPS requires you to register with them before using the API, but as far as I can tell, there is no charge for access to it. By the way, their API has some other features: you can standardize addresses and search for zip codes, as well as the entire set of tracking, delivery, labels, etc.

Using the Ziptastic HTTP / JSON API

This is a fairly new service, but according to their documentation, all you have to do is send a GET request to http://ziptasticapi.com , for example

 GET http://ziptasticapi.com/48867 

And they will return the JSON object line by line:

 {"country": "US", "state": "MI", "city": "OWOSSO"} 

Indeed, it works. You can verify this from the command line by doing something like:

 curl http://ziptasticapi.com/48867 
+11
source share
+5
source share
+2
source share

The Yahoo PlaceFinder API will work for this type of request.

http://developer.yahoo.com/geo/placefinder/guide/index.html

I think that

 http://where.yahooapis.com/geocode?appid=<appID>&postal=<zipCode> 

will provide you with what you are looking for.

+2
source share

Also http://www.zipwise.com/webservices provides XML and JSON results for free for zip code search, radius search, reverse search and latitude / longitude.

+1
source share

This can satisfy your need if you want to get information about the city / state:

http://www.usps.com/webtools/address.htm

Its the API you are subscribing to.

0
source share

All Articles