XML Weather Feeds
September 2nd, 2005

Yahoo just released rss weather feeds: http://weather.yahoo.com/rss.
This is fantastic. You can get current conditions as well as five-day forecast data. This is the same feed that is used by the Konfabulator widget.
The format of the URL for the feed is:
http://xml.weather.yahoo.com/forecastrss?p=USNY0996&u=f
p is a US zip or a Yahoo! Weather location ID
u is the temp. units. ‘F’ for Fahrenheit (default) and ‘C’ for celcius
A nice little addition to the feed is the latitude and longitude tags…
Here is a quick and dirty perl script that grabs the rss feed for my zip (10013) and prints the curr conditions and forecast to the screen. No error checking done (for readability)…
#!/usr/bin/perl -w
# grab weather xml from yahoo rss feed
use strict;
use LWP::Simple;
use XML::XPath;
my $data_url =
"http://xml.weather.yahoo.com/forecastrss?p=10013&u=f";
# get data and drop it in a file
my $xml_data = get ($data_url);
# use XPath to parse the file
my $xp = XML::XPath->new(xml => $xml_data);
# no error checking...
# current conditions
my $curr_cond =
$xp->find('/rss/channel/item/yweather:condition')->get_node(1);
print $curr_cond->find('@text') . ": " .
$curr_cond->find('@temp') . "\n\n";
# forecast
foreach my $forecast ($xp->find('/rss/channel/item/yweather:forecast')->get_nodelist)
{
print $forecast->find('@day') . ": " .
$forecast->find('@text') . ". " .
"High " . $forecast->find('@high') . ", " .
"Low " . $forecast->find('@low') . "\n";
}
National Weather Service
The National Weather Service has XML weather feeds available at http://www.weather.gov/xml/. You can get current conditions, forecasts, watch/warnings, etc… The current conditions have a REST API while the forecasts are SOAP.
For current conditions/observations, they have both RSS and CAP/XML feeds.
Examples of the feeds:
Central Park NYC RSS Feed
Central Park NYC XML Feed
Weather.com
You can sign up to get access to weather.com’s current conditions and forecast feeds at http://www.weather.com/services/xmloap.html. During the signup, they ask you what type of application the data will be used in and they throw a few pages of lame offers at you (“Sign me up for Timely Gardening Tips from Miracle-Gro”). wtf!?
I think the original Konfabulator widget used the weather.com feed…I seem to remember poking through the javascript at one point. Anyway, no need to go through the signup process for weather.com when you can use the Yahoo! or NWS feeds.
WeatherBug
WeatherBug released their weather API (REST) a few months ago: http://api.weatherbug.com/default.aspx.
You have to sign up and get a license code to use it.
According to the site, you can access:
- Live weather and wind data
- Severe weather alert checks
- 3-day forecasts
- 7-day highs and lows
I have yet to try this one out…