API to get Center point zip code of a City

2.7k views Asked by At

I am looking for an API that will give me all the zip codes within a 20 mile radius of a given US city. So far based on my online search, I could only find APIs that will give me all the zip codes with a 20 mile radius for a given zip code. Hence I’m trying to find an API that will (a) first find the zip code of the center point of a city, and then (b) use the API that I referred above to pass the zip code and the distance (e.g. 20 miles) to get all the zip codes within that 20 mile radius.

So I’m looking for (a) above, which is an API that will return the zip code of the center point of a city. This is all for US.

3

There are 3 answers

0
Rod Burns On

You can use the Google Geocoding API to get the location coordinates of a city, then use reverse geocoding to look up the actual zip code for that location.

Bear in mind if you get this data from Google you need to use it on a Google Map and are not supposed to use it outside of that.

0
Jeffrey On

If you want a flat file instead, to maintain the data yourself, the USGS Gazetteer Populated Places file has really good city centroid coordinates and is free to use.

0
Shreyas Chavan On

Use the Geocoding API from Google to first map the city to the corresponding lat-long pair. Then use the Geonames API to get the postal codes in nearby radius. Use the following format for the Geonames API

http://api.geonames.org/findNearbyPostalCodes?lat=47&lng=9&username=demo

Find more details here