Return Yahoo! weather API data in Celsius, using YQL

Whenever I had to call a temperature that I wanted in Celsius I just used a simple conversion function:

function FtoC(temp) {return Math.round((temp - 32) / (9 / 5));}

Then again, I wanted to toggle between Fahrenheit and Celsius. Just calling the Celsius JSON element from Yahoo is probably better if all you want to use is Celsius.


You can try this:

YQL Query:

select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="jiangmen,cn") and u="c"

EndPoint:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22jiangmen%2Ccn%22)%20and%20u%3D%22c%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

This work when I try just now


Better late than never...

var locationQuery = escape("select item from weather.forecast where woeid in (select woeid from geo.places where text='GB-LND') and u='c'"),
    locationUrl = "http://query.yahooapis.com/v1/public/yql?q=" + locationQuery + "&format=json&callback=?";

It's easier to read if you break it up. You we're pretty close, just needed the u=c as part of the query, not at the end of the url.


I used the yql

select item from weather.forecast where woeid=22724447 and u='c'

and it worked fine with the results in Celsius. I changed the "LEXX0003" for the real WOEID of that zone and it seems to have worked.

Tags:

Json

Yahoo

Yql