2

I have found yahoo weather forcast most helpful.

I'm able to get an hourly weather request here from Yahoo.

How can I make an API request for the above hourly weather report using an Yahoo API call to http://weather.yahooapis.com/forecastrss?w=2502265?

This is the documentation I found.

snumpy
  • 2,808
  • 6
  • 24
  • 39
Anoop P S
  • 754
  • 1
  • 12
  • 31
  • 1
    What tool are you trying to use to call the RSS feed? Do you want to display it on a webpage or in a desktop application (or something else)? – snumpy Apr 25 '13 at 11:24
  • to develop a web application, which displays weather hourly, finds yahoo weather api best suited http://developer.yahoo.com/weather, but i also found a [link] (http://in.weather.com/weather/hourByHour-INXX0104?cm_ven=yahoo_in&cm_cat=citypage&cm_ite=weather&cm_pla=hourly), how can we make yhoo api call for hourly weather – Anoop P S Apr 25 '13 at 11:28
  • #yahoo-weather-api – Rauan Jun 21 '17 at 18:26

2 Answers2

0

Yahoo Weather Api does not seem to support hourly forecasts, there are just a few parameters you have control over like the location in (woeid) or (lat, long) and the temperature-unit (u or f), refer here for yahoo query language.

You can use other api's AccuWeather for hourly details.

Akansh
  • 1,715
  • 3
  • 15
  • 34
-1

You can do using the REST API's of the programming language you want to use.. I will give Java example. (Similar thing applies to other languages too.. )'

package tests;

import org.apache.http.*;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

/**
 * A simple Java REST GET example using the Apache HTTP library.
 * This executes a call against the Yahoo Weather API service, which is
 * actually an RSS service (http://developer.yahoo.com/weather/).
 * 
 * Try this Twitter API URL for another example (it returns JSON results):
 * http://search.twitter.com/search.json?q=%40apple
 * (see this url for more twitter info: https://dev.twitter.com/docs/using-search)
 * 
 * Apache HttpClient: http://hc.apache.org/httpclient-3.x/
 *
 */
public class ApacheHttpRestClient1 {

  public static void main(String[] args) {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    try {
      // specify the host, protocol, and port
      HttpHost target = new HttpHost("weather.yahooapis.com", 80, "http");

      // specify the get request
      HttpGet getRequest = new HttpGet("/forecastrss?p=80020&u=f");

      System.out.println("executing request to " + target);

      HttpResponse httpResponse = httpclient.execute(target, getRequest);
      HttpEntity entity = httpResponse.getEntity();

      System.out.println("----------------------------------------");
      System.out.println(httpResponse.getStatusLine());
      Header[] headers = httpResponse.getAllHeaders();
      for (int i = 0; i < headers.length; i++) {
        System.out.println(headers[i]);
      }
      System.out.println("----------------------------------------");

      if (entity != null) {
        System.out.println(EntityUtils.toString(entity));
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      // When HttpClient instance is no longer needed,
      // shut down the connection manager to ensure
      // immediate deallocation of all system resources
      httpclient.getConnectionManager().shutdown();
    }
  }

There are more ways to do the same... you can find many other alternate ways at http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples

AurA
  • 12,135
  • 7
  • 46
  • 63
  • That a great help Aura.. I am on LAMP platform i am checking it..thanks – Anoop P S Apr 25 '13 at 12:01
  • if we click here [Link](http://in.weather.yahoo.com/united-states/maryland/california-2373278/) in the page just click hourly . We can see hourly report of the weather. I want to know how can we request as forcastrss just like (http://weather.yahooapis.com/forecastrss?w=2442047&u=c) as givein in the [Link] (http://developer.yahoo.com/weather/) – Anoop P S Apr 26 '13 at 04:22
  • Yes you can also make forcastrss request like given in the link http://developer.yahoo.com/weather/#req – AurA Apr 26 '13 at 04:34
  • yes, but how to request yahoo api call to get hourly data, the documentation doesnot specify how to make such request... – Anoop P S Apr 26 '13 at 04:46
  • in this page [page] (http://in.weather.yahoo.com/united-states/maryland/california-2373278/) if we click hourly in the forcast banner we get the hourl y data , hope u understant my doubt about how can query to the yahoo api to return the hourly day for a specific location – Anoop P S Apr 26 '13 at 04:49
  • @anoop It is very similar to the above solution... basically you get an xml which gives the forcast data eg.. http://weather.yahooapis.com/forecastrss?w=2442047&u=c the same link you mentioned... you can parse it using any language like in your case PHP on LAMP you can refer to this previous question http://stackoverflow.com/questions/1121933/parsing-xml-using-php , actually I work mainly on Java so I don't know about PHP xml parsing API's myself.. I hope the link to previous quesion help you in parsing xml . – AurA Apr 26 '13 at 05:50
  • yes thanks, aura i understand the return xml needs to be parsed but, the request format for hourly weather report has not mentioned in the yahoo weather documentation. to request this thi one is direct link from yahoo weather .(http://in.weather.com/weather/hourByHour-CAXX2147?cm_ven=yahoo_in&cm_cat=citypage&cm_ite=weather&cm_pla=hourly) – Anoop P S Apr 26 '13 at 06:05
  • 6
    I don't see how this answers the question. I, like the OP, want to get hourly forecast data for multiple days using an API (XML, JSON, whatever). But the links above all return (best I can tell) the current forecast. I want something like you get with this form: http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXML.htm – Matthew Cornell Feb 23 '15 at 15:17
  • This answer is not near to what @AurA is asking for. He needs hourly data of forecast as shown on yahoo weather pages. This answer is invalid. – Akansh Dec 21 '17 at 20:37