Question

I am using yahoo weather api to get weather information

This is returning an xml output.
I want to get it in JSON format. How can i get this as JSON?

Was it helpful?

Solution

I would suggest using YQL and requesting JSON output. The link you referenced is Yahoo's weather RSS feed.

http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20location%3D%2248907%22&format=json

OTHER TIPS

http://weather.yahooapis.com/forecastjson?w=2502265

Just replace forecastrss by forecastjson in the URL. I see one drawback: No weather-code is returned for the forecast.

Update 2014-06: This used to work, but seems to be gone since 2012-10 (see also https://developer.yahoo.com/forum/YQL/-/1349591762366-e0f8ad94-f599-49fe-bddb-fe3cd0180dea)

As per the documentation at http://weather.yahooapis.com/forecastrss, the rss response is xml.

The Weather RSS feed is an XML document that conforms to the RSS 2.0 specification. RSS is an XML document containing a single channel element representing the feed, several elements containing metadata about the feed itself, and one or more item elements describing individual items within the feed.

And so, you won't get the response as JSON

After a few search i found the yahoo weather api is best for me as what i really needed. To get the weather data from latitude and longitude

In XML (default)

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="({28.3949},{84.1240})")

In JSON format

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="({28.3949},{84.1240})")&format=json

Your ouput will be like below enter image description here

Put your own place latitude and longitude to find your location weather, hopefully this will help.

if you are looking for a JSON weather API I have a suggestion for you!
I made a Weather API available on mashape, and they have a ready to use simple PHP SDK. This api is really simple to use because we use the cool standards that are available nowadays, like JSON and REST, while our competitors still use legacy SOAP/XML systems.

Speaking about the quality of data Metwit (my "company") born as a crowdsourced platform for gathering real-time weather reports from real people. After more then ten thousand users started to using our apps and send a massive amount of reports, we decided to release those precious reports through our APIs.

We also act as single gateway for multiple, hard to parse, sources of forecasts like NOAA, and we're enhancing them with social data like photos, tweets, etc., that we leverage from existing social networks.

If you like it please give it a try on mashape!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top