views:

259

answers:

2

How to convert post code to city name, is there an API available?

+1  A: 

You need a service that does reverse geocoding.


Yahoo's Geocoder API is getting much better results globally.

110021 is the postal code for New Delhi among several other places in the world.

This seems to get them all.


Google Maps API is another such service but I'm not happy with the reverse geocoded results as I don't get all results back for 110021.

geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': '110021'}, function(results, status) {
    console.log(results);
});
Anurag
Hi Anurag, Thanks so much for that information. Acctually, I think your second answer gives me the best solution, cause I have long/lat information at hand, and want them to be converted to City/Country.I hope it works fine.Thanks,Ling
LingAi
@Ling, you can use the Yahoo API to convert lat/long to a city/country as well. See the documentation link to see what input params you can pass - http://developer.yahoo.com/maps/rest/V1/geocode.html
Anurag
Thanks all, I think Google API works for me. Cheers
LingAi
A: 

The US Post Office sells a subscription to map 5 digit zip codes to City/State values. As @Timothy says, the mapping is one to many. However, the post office db does mark which city/state is the "primary" for a given zip code.

Don't know about other countries. Check with your country's postal authority.

See http://www.usps.com/ncsc/addressinfo/citystate.htm

Larry K