AccuWeather is one of the standard widgets on my Android phone. I found no API wrapper for it after searching rubygems.org and I thought it would be fun to write one after spending a little time reverse engineering the web API (related post).
First, find a location via the city search API:
1 2 3 |
|
This returns a list of locations that match the input. Each location provides several pieces of information including a city identifier:
1 2 3 4 5 6 7 |
|
The gem caches over 175K cities around the world. If the location name
is not in the cache, the gem will
make a HTTP request to AccuWeather to try and find it.
The location identifier is used to get more information about current weather conditions:
1 2 3 4 5 6 |
|
A week of day and nighttime forecasts are available:
1 2 3 4 5 6 7 8 9 10 11 |
|
The API returns a weather_icon
number for the current weather and forecast. This number appears to correspond to PNG
file from AccuWeather.com. I downloaded the full set of PNG files and included them here, but found a handful of better
looking weather webfonts out there (links below).
Related resources:
- Full accuweather icon set (download ZIP)
- Weather Icons
- Meteocons
Accuweather gem links:
Stay warm out there and have fun!