I'm trying to grab a few values from the observation array within the In the history api from api.wunderground.com/api.
http://api.wunderground.com/weather/api/d/docs?d=data/history
I'm a novice with JavaScript but attempting to pull this data into Google Sheet using the json api.
I'm looking for help to get the temp and precip for various observations from yesterday's history. Special credit if you have creative way to get 6 (or every fourth) observations from 6:00am to 7:00pm. I'm just trying to get a random set from the daytime.
// Fetch Wunderground Weather from Yesterday
var urlwx = "http://api.wunderground.com/api/" + api + "/history_" + yesterday + "/q/" + country + "/" + city + ".json" ;
var wxresponse = UrlFetchApp.fetch(urlwx);
Logger.log(urlwx)
// Parse the JSON reply
var wxcontentText = wxresponse.getContentText();
var historywx = JSON.parse(wxcontentText);
** //Get Temps this is where I'm stuck **
var yesterdayMaxTemp = historywx.history.observations[0].tempi;
var yesterdayPrecip = historywx.history.observations[0].precipi ;
Looks like this was working - I'm still open to ideas on how to improve getting temps over multiple observations. For now, I grabbed every fifth observation and declared a variable for each. I'm sure there's a better way and I'm open to suggestions.