1

I need to programmatically find approximate postal/zip code for a given city. When I use this link:

http://maps.googleapis.com/maps/api/geocode/xmladdress=vancouver,BC,Canada&components=country:CA

it brings me all location information except postal code. Is there a way to get a postal code using only city name?

Aslan
  • 148
  • 7

2 Answers2

1

Likely not, as cities can have multiple zip codes.

At least for the US, you could look at the "Hold For Pickup Facility Information" api from the USPS

https://www.usps.com/business/web-tools-apis/address-information.htm (scroll down a bit)

This returns a list of us postal facilities in a given city, from which you could glean a list of (at least some) zip codes in the area.

Ben Bartle
  • 1,080
  • 11
  • 12
  • And similarly for Canada: http://www.canadapost.ca/cpo/mc/business/productsservices/developers/services/findpostoffice/default.jsf – Ben Bartle May 13 '14 at 18:50
  • You are right. There are multiple zip codes with in cities. I was wondering if there is a way to get one of the downtown zip codes by using google map api. – Aslan May 13 '14 at 19:02
  • It looks like some one has figured out how to get it from latitude/longitude, so if your google api call gets that you could be set http://stackoverflow.com/questions/3564852/get-zip-code-from-latitude-longitude – Ben Bartle May 13 '14 at 19:12
0

I have looked around a lot. Ben is right. It is not possible to get postal codes by using only city names. You need full address. However you can get postal code of a coordinate. It requires too many api calls but if you have the coordinates of the city you can get the postal code easily.

Aslan
  • 148
  • 7