Getting a ‘Feels Like’ Temperature when transitioning away from the Weather Underground API

IBM has made the disappointing decision to retire the Weather Underground API effective 12/31, leaving many developers scrambling due to the abruptness of this decision and the complete lack of roadmap or guidance as to how to transition to a replacement so that their applications will work on January 1st.

One key element of the Weather Underground API that my popular tutorial for making an Alexa Skill makes use of is the ‘feels-like’ temperature. When updating this tutorial due to the bad news I chose to transition this tutorial to the OpenWeatherMaps API, which offers a free tier like the Weather Underground API used to that allows for up to 60 requests per minute and the current weather.

While it does not offer a ‘feels-like’ temperature, this can be easily calculated by simply factoring in wind chill to the temperature you report. This means you do not need to use OpenWeatherMaps- you can really use any API that gives you a current temperature and wind speed! It really is as simple as this:

 


var http = require( 'http' );
var url = 'http://api.openweathermap.org/data/2.5/weather?zip=<YOURZIP&gt;,us&units=imperial&APPID=<YOURAPPID>';
http.get( url, function( response ) {
var data = '';
response.on( 'data', function( x ) { data += x; } );
response.on( 'end', function() {
var json = JSON.parse( data );
var temp = json.main.temp;
var wind_speed = json.wind.speed;
var wind_chill = 35.74 + 0.6215*temp 35.75*Math.pow(wind_speed, 0.16) + 0.4275*temp*Math.pow(wind_speed, 0.16);
var chill_rounded = Math.round( wind_chill * 10 ) / 10;
} );
} );

view raw

feels like.js

hosted with ❤ by GitHub

The formula in the above code is to calculate a temperature with windchill using US Customary units:

Wind Chill = 35.74 + 0.6215T – 35.75(V^0.16) + 0.4275T(V^0.16) (Courtesy of MentalFloss)

where T is a temperature in Fahrenheit and V is a wind speed in MPH. You should be able to find a corresponding formula for metric online.

I also went ahead and rounded my ‘feels like’ temperature to one decimal place, to make it easier to read (or for a voice assistant to read out loud, which is how I eventually used this code).

I hope this helps others as they transition to other weather APIs as Weather Underground winds down. Its developer community will be missed!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s