In 2012 The Weather Channel acquired Weather Underground, a service developed from two decades of work that began with a few graduate students in meteorology at the University of Michigan. Although it’s a commercial entity, Weather Underground uses a large network of personal weather stations for gathering weather data across the planet. With the acquisition, The Weather Channel now has access to that data, as well as an API for accessing the data. Therefore, The Weather Channel now offers an API that is part of both The Weather Channel and Weather Underground.
The Weather Underground APITrack this API (or, Wunderground) includes what you might expect, including current weather conditions and forecasts for specific locations, as well as historical data and planner data. But it also provides a great deal of other data. For example, through an API call I could determine the moon's phase, the time of sunset, and height of the tide. (A list of the data types the Weather Underground API supports can be found in the Weather Underground documentation.
As with many APIs, you need to sign up and obtain a key in order to access the Weather Underground’s data. Just be mindful of limits per minute and per day.
Using the API is simply a matter of sending GET requests along with your security key. Because it's just a GET, you can paste the URLs right in the browser, as well as use them in your own code. Here's a simple HTTP GET that shows the current warnings for my area.
Using the API
The first thing to know about the API is how to specify a location. You can use a latitude and longitude; or you can search by city, ZIP code (for U.S. cities only) or airport code. You can also specify the ID of a Weather Underground weather station if you know it.
To piece together the URL for an API call, you start with the standard endpoint:
Add on your security key, which is a string of hex digits. Then provide the name of the type of data you're requesting, which Weather Underground calls features.
In your URL you also can include an optional setting. There are a few, but one important one is language. The default is English; if you want to use, for example, French, you input lang:FR.
So far, our URL looks like this:
Or, with a language:
Next, add on the location search using one of the methods described earlier. So, let's piece together a couple of URLs, grabbing alerts for the city of Warsaw, Mo., which had a tornado warning as I was writing this article.
In the case of alerts, you must choose either XML or JSON--by appending .xml or .json, respectively.
When I put this URL in my browser, I got back the full data on the current tornado warning, including a field that contained text from the National Weather Service. It started out, “The National Weather Service in Springfield has issued a * Tornado Warning for... southwestern Benton County in central Missouri...”