Yahoo Weather API is a great weather condition source, which you can use on your apps free of charge. Many apps use it, like the StormCloud, Drupal and Joomla modules and many applications for smart phones. The iOS main weather application retrieves weather condition from Yahoo too.
But how can you use it to your applications and retrieve forecast for 5 days?
The place I live is called Agia Paraskevi, which is in Athens - Greece, and I will use it as an example at the following codes. The Yahoo weather API exchange data using the RSS and XML formats. So, you have to be familiar with these formats to use it. To get the info you need you have only to request data using specific URLs and parameters.
The first thing we need is to find the place WOEID, which is a unique ID number. To get this you have to access the URL http://query.yahooapis.com/v1/public/yql with two parameters, the
q which is an SQL query that includes your living town name, and the
format which we set to
xml. Have in mind that the URL should be encoded as one, before you access it.
The above url will return an XML page where we can find the WOEID at the first data child and under the tag:
Among other info we can get the name of the place as Yahoo provides it, under the tag
So, we have now the WOEID of our place of living. Using this we can get the weather condition by accessing the following URL. The
w parameter is the WOEID number.
The return data from the above URL is an RSS with the place weather condition and a forecast for 2 days. So you have now your basic weather condition info.
If we would like to get more than 2 days forecast, we first have to find the global zip code (GUID) of the place. This can be found at the end of the previous RSS result, with the tag:
Using the GUID “GRXX0012” and the following URL we can get 5 days forecast, in RSS format again. The
_c extension at the URL will return the degrees in Celsius unit, but the
_f in Fahrenheit unit.
That’s all you have to do to get the weather condition info. This can be used with any programming language you like.