Yahoo weather-api response as json
Asked Answered
B

5

18

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?

Bitner answered 15/2, 2011 at 7:32 Comment(0)
E
26

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

Endostosis answered 15/2, 2011 at 7:54 Comment(5)
how can i pass params in the above query suchs as latitude,longitude or only woeid to get weather.Bitner
yql weather forecast only for US!Epizoon
Actually, you can put the location of any city in the world, in http://weather.com search for the city you want, and in the URL is going to show the ID that you need to use in the query: For Tokyo, Japon: JAXX0085 For México city: MXDF0132 ... Greetings!Schoolboy
the YQL method will be based on two parameters only. WOEID and Unit. Remember that YQL weather.forecast can only be used to get a two days forecast maximum.Peaslee
You can use a YQL subquery to use lat/long from geolocation: select * from weather.forecast where woeid in (SELECT woeid FROM geo.placefinder WHERE text="34.0485508,-84.22675029999999" and gflags="R")Tatro
S
8

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)

Suet answered 12/5, 2011 at 10:25 Comment(1)
This seems to work, but I am unable to find documentation for it. There is however documentation for forecastrss. Strange.Adamson
M
2

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

Makeup answered 15/2, 2011 at 7:55 Comment(0)
L
1

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!

Lesbianism answered 29/1, 2013 at 15:22 Comment(0)
M
1

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.

Mailbox answered 7/9, 2016 at 12:26 Comment(1)
Thanks, it works and you even don't need to use authorization.Dialectologist

© 2022 - 2024 — McMap. All rights reserved.