View Single Post
Old 12-17-2012, 03:24 PM   #77
Junior Member
FeRDNYC began at the beginning.
Posts: 1
Karma: 10
Join Date: Dec 2012
Device: none
Originally Posted by KevinShort View Post
Hmm, accuweather might work. I have used a desktop weather script that
fetched data from accuweather, and it was quite accurate. As you said, the
city code could be a problem, but I'll look into it. Thanks for the suggestion!
For the Gnome Shell weather extension (a statusbar "gadget" displaying conditions and forecasts), we get our data from Yahoo Weather.

They have a pretty good free API and sensible policies (each user isn't forced to obtain their own separate API key, like with and some others), they actually supply a lot of nice detail for the current conditions (humidity, pressure, wind conditions, sunrise/sunset times, lunar phase IIRC), and it's available worldwide with reportedly pretty good accuracy.

The down side is, they only supply two days of forecast data. So you're limited to the current conditions, plus tomorrow and tomorrow+1 forecasts... no five-day. So, it's a tradeoff.

There appears to be a python wrapper pre-built, but that was last updated in 2009 so I'm a bit pessimistic about it. (If nothing else, it'll work against Yahoo's older, deprecated API, which doesn't seem wise.)

Honestly, I'm not sure a wrapper is necessary; the Shell extension just implements the interface directly, building a request URL that retrieves all of the weather data as a single JSON dump, which is then parsed. Their official API (which we're not quite using) offers either RSS or XML, and a good XML parsing library would probably serve just as well, if not better than a purpose-built API.

In fact, here's a Yahoo Developer Network article titled Parse XML using Python that actually uses the Weather API as an example.


The currently-active fork of the weather extension code lives in github, if you're looking for inspiration, tho there a few things done "wrong" for legacy reasons. (Including the use of deprecated Yahoo Location IDs, not WOEIDs ("Where On Earth IDs"), despite what the code/docs say. That, you definitely don't want to emulate; use the WOEIDs.)

Gnome Shell extensions are written in JavaScript, not Python, but as I said the request/response processing is pretty basic. All of the Yahoo Weather interaction specifically lives in extension.js starting with get_weather_url() @ line ~273.

Speaking of WOEIDs, users will need theirs. We have a Location ID lookup tool in our configurator (finally!), but for an embedded system it probably makes sense to just have users do an external lookup and configure their WOEID in place of the lat/long values.

Yahoo's API docs recomend going to, looking up weather for your target location, and then pulling the WOEID out of the result URL. I suppose that's one option, and certainly the easiest official path since their GeoPlanet API does require an API key for lookup requests (!?!), but there are third-party tools like out there that have already gone through all of that hassle.

...It's a great-looking weather station, BTW awesome project! Really cool stuff. Makes me wish I had a Kobo of my own to play with. :-)
FeRDNYC is offline   Reply With Quote