Important API update: We have made some updates to our service and from now on please send your app id through the "X-Yahoo-App-Id" header. We have also updated our documentation page and sample codes to reflect this change. Please refer to them as you see need. Please note that the "Yahoo-App-Id" header will be deprecated soon and after that request without the "X-Yahoo-App-Id" will be rejected.

Yahoo Weather API Documentation

The Weather RSS feed enables you to get up-to-date weather information for your location. You can save this feed in My Yahoo! or your favorite feed aggregator, or incorporate the RSS data into your own web site or client application. The Weather RSS feed is a dynamically-generated feed based on location, latitude & longitude or woeid.

This page describes the format of the Weather request URL and the RSS response for developers. It contains these sections:

Query Request

The Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add parameters and values after a question mark (?). Multiple parameters are separated by an ampersand (&).

The API is OAuth1 protected and needs to sign the request with a Yahoo App consumer key and secret. Please read through code example for sample OAuth1 call to our API.

The base URL for the Weather RSS feed is

https://weather-ydn-yql.media.yahoo.com/forecastrss

In this section, Summary shows how to make an RSS request with different parameters; Request Parameters shows a table summarizing those parameters.

Summary

For the Weather RSS feed we support querying by location (city name), latitude & longitude (number) or woeid (number):

  • location for location string.
  • lat&lon for latitude & longitude number.
  • woeid for woeid number. To find out woeid, see here.

For example, to get weather for Yahoo! Headquarters in Sunnyvale, CA, all of the following will work:

https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca

https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale

https://weather-ydn-yql.media.yahoo.com/forecastrss?lat=37.372&lon=-122.038

https://weather-ydn-yql.media.yahoo.com/forecastrss?woeid=2502265

By default, the response is returned in XML format. You can supply a "format" parameter in the query to get JSON response:

https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json

By default, the units of response are in imperial format. You can supply a "u" parameter in the query to get metric format:

https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&u=c

Request Parameters

Parameter Description Example
location city name location=sunnyvale,ca or location=shanghai,cn
lat latitude number lat=37.372
lon longitude number lon=-122.038
format response format format=xml (default) or format=json
u unit format u=f (default) or u=c
woeid woeid number woeid=2502265

Units

Units for imperial and metric format are shown below.

Imperial ("u=f") Metric ("u=c")
Temperature Fahrenheit Celsius
Distance Mile Kilometer
Wind Direction Degree Degree
Wind Speed Mile Per Hour Kilometer Per Hour
Humidity Percentage Percentage
Pressure Inch Hg Millibar

Get woeid

We don't have API to get woeid for now. To find your woeid, browse or search for your city from Yahoo Weather page. The woeid is in the URL for the forecast page for that city. You can also get the woeid by entering your zip code on that page. For example, if you "Change location" for Sunnyvale, the forecast page for that city is https://www.yahoo.com/news/weather/united-states/sunnyvale/sunnyvale-2502265. The woeid is 2502265. Also you can find woeid from the API response.

Code examples

Few notes when you are querying the API

  • Our code examples are just for illustration purpose. Never expose the consumer secret in your code.
  • Make sure all the query parameters ("location", "format", "u", etc) along with oauth parameters are sorted and encoded when generating the signature.
  • Our code examples are trying to illustrate the implementation with native language. There are plenty of libraries out there to ease OAuth1 request.

Code samples on this page are Copyright 2019, Oath Inc. Licensed under the terms of the zLib License.

RSS Response

The Weather RSS feed is an XML document that conforms to the RSS 2.0 specification. RSS is an XML document containing a single channel element representing the feed, several elements containing metadata about the feed itself, and one or more item elements describing individual items within the feed.

The Weather RSS feed also includes additional elements from the geo vocabulary as well as a custom yweather vocabulary.

Top-Level Elements

Element Description
xml The Weather RSS feed conforms to XML 1.0. No child elements.
rss The Weather RSS feed conforms to RSS 2.0.
Child elements: channel

Channel Elements

The channel element contains metadata about the feed and its contents.

Element Description
title The title of the feed, which includes the location city. For example "Yahoo! Weather - Sunnyvale, CA"
link The URL for the Weather page of the forecast for this location
language The language of the weather forecast, for example, en-us for US English.
description The overall description of the feed including the location, for example "Yahoo! Weather for Sunnyvale, CA"
lastBuildDate The last time the feed was updated. The format is in the date format defined by RFC822 Section 5, for example Mon, 256 Sep 17:25:18 -0700.
ttl Time to Live; how long in minutes this feed should be cached.
yweather:location The location of this forecast. Attributes:
  • city: city name (string)
  • region: state, territory, or region, if given (string)
  • country: two-character country code. (string)
yweather:units Units for various aspects of the forecast. Attributes:
  • temperature: degree units, f for Fahrenheit or c for Celsius (character)
  • distance: units for distance, mile for miles or km for kilometers (string)
  • pressure: units of barometric pressure, inchHg for Inch of mercury or mbar for millibars (string)
  • speed: units of speed, m/h for miles per hour or km/h for kilometers per hour (string)
Note that the default RSS feed uses Fahrenheit degree units and English units for all other attributes (miles, inchHg, miles per hour). If Celsius has been specified as the degree units for the feed (using the u request parameter), all the units are in metric format (Celsius, kilometers, millibars, kilometers per hour).
yweather:wind Forecast information about wind. Attributes:
  • chill: wind chill in degrees (integer)
  • direction: wind direction, in degrees (integer)
  • speed: wind speed, in the units specified in the speed attribute of the yweather:units element (m/h or km/h). (integer)
yweather:atmosphere Forecast information about current atmospheric pressure, humidity, and visibility. Attributes:
  • humidity: humidity, in percentage (integer)
  • visibility, in the units specified by the distance attribute of the yweather:units element (mile or km).
  • pressure: barometric pressure, in the units specified by the pressure attribute of the yweather:units element (inchHg or mbar). (float).
  • rising: state of the barometric pressure: steady (0), rising (1), or falling (2). (integer: 0, 1, 2)
yweather:astronomy Forecast information about current astronomical conditions. Attributes:
  • sunrise: today's sunrise time. The time is a string in a local time format of "h:mm am/pm", for example "7:02 am" (string)
  • sunset: today's sunset time. The time is a string in a local time format of "h:mm am/pm", for example "4:51 pm" (string)
image The image used to identify this feed. See Image Elements for element descriptions
Child elements: url, title, link, width, height
item The local weather conditions and forecast for a specific location. See Item Elements for element descriptions.
Child elements: title, link, description, guid, pubDate, geo:lat, geo:long, yweather:forecast

Image Elements

The image element describes an image or icon used to identify the feed.

Element Description
title The title of the image, for example "Yahoo! Weather"
link The URL of Yahoo! Weather
url The URL of the image
width The width of the image, in pixels
height The height of the image, in pixels

Item Elements

The item element contains current conditions and forecast for the given location. There are multiple yweather:forecast elements for today and tomorrow.

Element Description
title The forecast title and time, for example "Conditions for New York, NY at 1:51 pm EST"
link The Yahoo! Weather URL for this forecast.
description A simple summary of the current conditions and tomorrow's forecast, in HTML format, including a link to Yahoo! Weather for the full forecast.
guid Unique identifier for the forecast, made up of the location ID, the date, and the time. The attribute isPermaLink is false.
pubDate The date and time this forecast was posted, in the date format defined by RFC822 Section 5, for example Mon, 25 Sep 17:25:18 -0700.
geo:lat The latitude of the location.
geo:long The longitude of the location.
yweather:condition The current weather conditions. Attributes:
  • text: a textual description of conditions, for example, "Partly Cloudy" (string)
  • code: the condition code for this forecast. You could use this code to choose a text description or image for the forecast. The possible values for this element are described in Condition Codes (integer)
  • temp: the current temperature, in the units specified by the yweather:units element (integer)
  • date: the current date and time for which this forecast applies. The date is in RFC822 Section 5 format, for example "Wed, 30 Nov 2005 1:56 pm PST" (string)
yweather:forecast The weather forecast for a specific day. The item element contains multiple forecast elements for today and tomorrow. Attributes:
  • day: day of the week to which this forecast applies. Possible values are Mon Tue Wed Thu Fri Sat Sun (string)
  • date: the date to which this forecast applies. The date is in "dd Mmm yyyy" format, for example "30 Nov 2005" (string)
  • low: the forecasted low temperature for this day, in the units specified by the yweather:units element (integer)
  • high: the forecasted high temperature for this day, in the units specified by the yweather:units element (integer)
  • text: a textual description of conditions, for example, "Partly Cloudy" (string)
  • code: the condition code for this forecast. You could use this code to choose a text description or image for the forecast. The possible values for this element are described in Condition Codes (integer)

Sample Response

A sample RSS response is shown below:

JSON Response

To get the forecast for Yahoo! Headquarters in Sunnyvale, CA in JSON format:

https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json

Sample Response

A sample JSON response is shown below:

Condition Codes

Condition codes are used in the response to describe the current conditions.

Code Description
0 tornado
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
9 drizzle
10 freezing rain
11 showers
12 rain
13 snow flurries
14 light snow showers
15 blowing snow
16 snow
17 hail
18 sleet
19 dust
20 foggy
21 haze
22 smoky
23 blustery
24 windy
25 cold
26 cloudy
27 mostly cloudy (night)
28 mostly cloudy (day)
29 partly cloudy (night)
30 partly cloudy (day)
31 clear (night)
32 sunny
33 fair (night)
34 fair (day)
35 mixed rain and hail
36 hot
37 isolated thunderstorms
38 scattered thunderstorms
39 scattered showers (day)
40 heavy rain
41 scattered snow showers (day)
42 heavy snow
43 blizzard
44 not available
45 scattered showers (night)
46 scattered snow showers (night)
47 scattered thundershowers

Attribution Guidelines

Thank you for being a part of Yahoo Developer Network community, that helps Yahoo to be part of your users’ daily habits. Please follow our Attribution Guidelines for Yahoo APIs wherever you use Weather data from Yahoo.

Commercial Use

If you want to use weather API for commercial purpose, please request an invite here.

Terms of Use

The above feeds are provided free of charge for use by individuals and non-profit organizations for personal, non-commercial uses. We reserve all rights in and to the Yahoo logo, and your right to use the Yahoo logo is limited to providing attribution in connection with these RSS feeds. Yahoo also reserves the right to require you to cease distributing these feeds at any time for any reason. Usage of these feeds is subject to YDN terms of use. Your use of weather feeds is subject to the Yahoo APIs Terms of Use