using postal code with HTML interface

  • 1
  • Question
  • Updated 3 years ago
Hi, all -

I realize that this question isn't strictly about the API, but I'm hopeful someone can help me with this. Besides, if I can't find an answer, I'll probably have to go with the API.

I have an application that needs to return weather forecasts for locations in the USA and Canada. The URL we form looks like:

https://www.wunderground.com/{Country}/{State/Province]/{City}.json?MR=1

This works in most cases, but we've found instances where the user DB has anachronistic city names. For example, the city Nepean was incorporated into Ottawa in 2001. Even though users are by convention using the old name (which seems to be OK with the postal service), it doesn't produce a valid page when plugged into the address bar. Further complicating the exercise is that the window.open() call from JavaScript still returns a success code even if the location isn't found, so the 404 error is seemingly hidden from me.

It occurs to me that we might be able to obviate this problem by using postal codes instead of country/state/city, but I don't know whether the HTML interface permits this, and if so, what the syntax is. Can anyone shine some light on this?

If this can't be done, I wonder whether there's some service (within wunderground or otherwise) that accepts a postal code and returns the necessary information to form the URL above.

Thank you for any help on this.
Photo of Michael Zimmers

Michael Zimmers

  • 2 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Ravi Yadav

Ravi Yadav

  • 82 Posts
  • 9 Reply Likes
You can make an API request using zipcode: 
http://api.wunderground.com/api/APIKey/geolookup/q/M4B1B4.json
Photo of Michael Zimmers

Michael Zimmers

  • 2 Posts
  • 0 Reply Likes
Thank you, Ravi. I was hoping I could do this via the HTML interface, so that I don't have to format a page myself. If there's a way to do that, I'd greatly like to hear about it.