Webservice to get City Names by giving Zip Codes [

2019-03-16 02:27发布

I need a reliable webserivce which gives corresponding city name by passing zip code. This webservice should work at any time. This webservice will be used in the production also.

6条回答
Anthone
2楼-- · 2019-03-16 02:31

This may suite your need if you want something to obtain city/state information:

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

Its a API in which you sign up for.

查看更多
Anthone
3楼-- · 2019-03-16 02:47
SAY GOODBYE
4楼-- · 2019-03-16 02:52

I found a couple of ways to do this with web based APIs. I think the US Postal Service would be the most accurate, since Zip codes are their thing, but Ziptastic looks much easier.

Using the US Postal Service HTTP/XML API

According to this page on the US Postal Service website which documents their XML based web API, specifically Section 4.0 (page 22) of this PDF document, 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 corresponding City and State.

According to their documentation, here's what you would send:

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

And here's what you would receive back:

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

USPS does require that you register with them before you can use the API, but, as far as I could tell, there is no charge for access. By the way, their API has some other features: you can do Address Standardization and Zip Code Lookup, as well as the whole suite of tracking, shipping, labels, etc.

Using the Ziptastic HTTP/JSON API

This is a pretty new service, but according to their documentation, it looks like all you need to do is send a GET request to http://ziptasticapi.com, like so:

GET http://ziptasticapi.com/48867

And they will return a JSON object along the lines of:

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

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

curl http://ziptasticapi.com/48867 
查看更多
在下西门庆
5楼-- · 2019-03-16 02:53

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

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

I believe that

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

will get you what you're looking for.

查看更多
beautiful°
6楼-- · 2019-03-16 02:55
劫难
7楼-- · 2019-03-16 02:56

Also http://www.zipwise.com/webservices gives XML and JSON results for free for zip code lookups, radius searches, reverse lookups, and latitude/longitude stuff.

查看更多
登录 后发表回答