Get zip code based on lat & long?

It is called Reverse Geocoding (Address Lookup). To get address for lat: 40.714224, lng: -73.961452 query http://maps.googleapis.com/maps/api/geocode/json with parameters latlng=40.714224,-73.961452&sensor=true (example) and it returns JSON object or use http://maps.googleapis.com/maps/api/geocode/xml to return XML response (example). It's from Google and it's free.


For the Google API, you need to use it within a Google map, according to their site:

Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.


Please have a look on http://geonames.org. There is a webservice findNearbyPostalCodes (international).

Example: findNearbyPostalCodesJSON?lat=47&lng=9&username=demo

Shortened output:

{
  "postalCodes": [{
    "adminCode3": "1631",
    "distance": "2.2072",
    "postalCode": "8775",
    "countryCode": "CH",
    "lng": 8.998679778165283,
    "placeName": "Luchsingen",
    "lat": 46.980169648620375
  }]
}

Limit of the demo account is 2000 queries per hour.