Aaron Calvo
Aaron Calvo

Reputation: 21

google geocoding api services with zip code 12593

I am having an issue with google geo-loaction services. essentially we are using it for a zip code validator and there is an issue with zip code '12593'. This zip code is showing as being in Spain. (see screenshot here = http://prntscr.com/hkkafh.

See xml here https://maps.googleapis.com/maps/api/geocode/xml?&address=12593)

This zip code though is a USA based zip code as can be seen here = https://www.google.com/search?num=100&q=us+zip+code+12593&oq=us+zip+code+12593 (google search results.)

I understand that google is not the othority on zip codes however I would expect google to understand that this zip code may have two seperate locations.

any idea How I can get the api to understand I am looking for zip codes specifically in the USA?

Upvotes: 0

Views: 1043

Answers (2)

nkkumawat
nkkumawat

Reputation: 693

Alternatively you can use https://thezipcodes.com/ Get the API key from account Section. Hit the get request. I found majority of data here.

https://thezipcodes.com/api/v1/search?zipCode={zipCode}&countryCode={2digitCountryCode}&apiKey={apiKey}

response will be like

{
    "success": true,
    "location": [{
      "zipCode": "13040",
      "country": "United States",
      "countryCode2": "US",
      "countryCode3": "USA",
      "state": "New York",
      "stateCode2": "NY",
      "city": "Cincinnatus",
      "county": "Cortland",
      "latitude": "42.564381",
      "longitude": "-75.934792",
      "timeZone": "EST — Eastern Standard Time"
    }]
}

Upvotes: 0

Niloct
Niloct

Reputation: 9995

The zip code you're trying to find isn't reachable by the geocoding api. This near one is reachable:

https://maps.googleapis.com/maps/api/geocode/json?&components=country:US|postal_code:12516

To search by zip code and restrict by country (i.e. US), you must use the subparameters of the components query parameter like in the URL above

...&components=country:US|postal_code:[YOUR PARAMETER]

(got this parameter info on https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering)

Upvotes: 1

Related Questions