How I can get the right URL structure for hourly weather?

  • 1
  • Question
  • Updated 5 years ago
Hey guys,

How do I can get always the same structure to use in my URL for the API?
For example: I want to show to the user, hourly information about the weather, but I don't know which city they want, because they will add the cities themselves.

But on the API, I can see that in some cases, the URL is:

http://api.wunderground.com/api/[myke...

It means, the structure is STATE/CITY, but in some cases, I have to use COUNTRY/CITY, for example in:

http://api.wunderground.com/api/[myke...

How can I use the hourly information and get always right information?
Photo of cesarzeppini2

cesarzeppini2

  • 3 Posts
  • 0 Reply Likes
  • concerned

Posted 5 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
if you look forward for a city input from user, you shoul dlook at http://www.wunderground.com/weather/a...

otherwise, you could get someway latitude and logitude of city you need, and just query using this parameters couple, overriding the state/country issue
Photo of cesarzeppini2

cesarzeppini2

  • 3 Posts
  • 0 Reply Likes
Thanks for the quick reply.
I just need to understand one more thing. I will use Autocomplete, but, I don't understand how to build an URL with the info coming from Autocomplete.

For example. If I search "Indaiatuba" on the autocomplete, is perfect. Comes the country and city, everything I need to build an URL.

But in the case I told you before, as San Francisco, if I use /US/San_Francisco.json, it doesn't bring the right information. How should I use the info from Autocomplete to get the weather properly?
Photo of cesarzeppini2

cesarzeppini2

  • 3 Posts
  • 0 Reply Likes
Ok, making some tests, I realized I can use the ZMW, that is like a ID for the locations, and this ZMW is exclusive data from Wunderground, am I right?

Is there a way of, instead using the ZMW, use the cities themselves to build the URL? I made many tests, and most of them works with the cities, but when it comes to US, is always a problem. And I don't know if there is other countries with same problem. Can you guys help me on this?
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Please mind that since ZMW relies from zip codes, there is no guarantee to work in long term for current values (mixes zip, wmo code and some of "magic").

At the moment, the available queries to interact with WU API are listed at http://www.wunderground.com/weather/a... , as you can see united states enjoys from privileged case, so you may need to find your way to query for a city that fits best for your needs.