Yahoo weather API usage notes, Yahoo weather api

Source: Internet
Author: User
Tags in degrees yahoo weather api

Yahoo weather API usage notes, Yahoo weather api
Base_url:
Https://query.yahooapis.com/v1/public/yql? Q =, public query interface, limited query times
Https://query.yahooapis.com/v1/yql? Q =: Get the ApkId after registration. There is a limit on the number of queries, but it is enough. 0.1 million times/day


Step 1: locate the user's location on the mobile phone end (query by IP address, or ....), Obtain the name of the city where the user is located, the Pinyin of the city name, or the latitude and longitude.

Step 2: Obtain the woeid based on the Chinese characters, English letters, and longitude and latitude of the city where the user is located:


1. Here, the text key value can be in Chinese, English, latitude and longitude. For example


1): select * from geo. placefinder where text = "Guangzhou"


2): select * from geo. placefinder where text = "Beijing"


3): select * from geo. placefinder where text = "39.9919336, 116.3404132" and gflags = "R"


2. query the woeid of a city using the following url:
Https://query.yahooapis.com/v1/public/yql? Q = select * from geo. placefinder where text = "39.9919336, 116.3404132" and gflags = "R" & format = json
Https://query.yahooapis.com/v1/public/yql? Q = select * from geo. placefinder where text = "Beijing" & format = json
Https://query.yahooapis.com/v1/public/yql? Q = select * from geo. placefinder where text = "Guangzhou" & format = json


Note that the fglags parameter is missing only when woeid is obtained by latitude and longitude ., And gflags = "R" must be added.


Returned xml format data:
<Query xmlns: yahoo = "http://www.yahooapis.com/v1/base.rng" yahoo: count = "1" yahoo: created = "2015-05-28T03: 28: 29Z" yahoo: lang = "en-US">
<Results>
<Result>
<Quality> 40 </quality>
<Latitude> 23.12911 </latitude>
<Longlinks> 113.26336 </longlinks>
<Offsetlat> 23.12911 </offsetlat>
<Offsetron> 113.26336 </offsetlon>
& Lt; radius & gt; 17700 & lt;/radius & gt;
<Name/>
<Line1/>
<Line2> Guangzhou </line2>
<Line3> Guangdong </line3>
<Line4> People's Republic of China </line4>
<House/>
<Street/>
<Xstreet/>
<Unittype/>
<Unit/>
<Postal/>
<Neighborhood/>
<City> Guangzhou </city>
<County/>
<State> Guangdong </state>
<Country> People's Republic of China </country>
<Countrycode> CN </countrycode>
<Statecode> 44 </statecode>
<Countycode/>
<Hash/>
<Woeid> 2161838 </woeid>, which is the required woeid.
<Woetype> 7 </woetype>
</Result>
</Results>
</Query>
<! -- Total: 11 -->






Step 3: query the weather data based on the woeid returned in the preceding results:
1): place the woeid obtained in step 1 to the following query statement:
Select * from weather. forecast where woeid = 2502265 and u = "c"


2): use the following url to obtain the weather data:
Https://query.yahooapis.com/v1/public/yql? Q = select * from weather. forecast where woeid = 2502265 and u = "c" & format = json


Returned xml format data:


<Query xmlns: yahoo = "http://www.yahooapis.com/v1/base.rng" yahoo: count = "1" yahoo: created = "2015-05-28T03: 24: 54Z" yahoo: lang = "en-US">
<Results>
<Channel>
<Title> Yahoo! Weather-Sunnyvale, CA </title>
<Link>
Bytes
</Link>
<Description> Yahoo! Weather for Sunnyvale, CA </description>
<Language> en-us </language>
<LastBuildDate> Wed, 27 May 2015 pm PDT </lastBuildDate>
<Ttl> 60 </ttl>
<Yweather: location xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" city = "Sunnyvale" country = "United States" region = "CA"/>
<Yweather: units xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" distance = "km" pressure = "mb" speed = "km/h" temperature = "C"/>
<Yweather: wind xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" chill = "15" direction = "350" speed = "19.31"/>
<Yweather: atmosphere xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" humidity = "78" pressure = "1016.7" rising = "1" visibility = "16.09"/>
<Yweather: astpolicmy xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" sunrise = "5:50 am" sunset = "8:19 pm"/>
<Image>
<Title> Yahoo! Weather </title>
<Width> 142 </width>
<Height> 18 <Link> http://weather.yahoo.com </link>
<Url>
Http://l.yimg.com/a/ I /brand/purplelogo//uh/us/news-wea.gif
</Url>
</Image>
<Item>
<Title> Conditions for Sunnyvale, CA at 7: 55 pm PDT </title>
<Geo: lat xmlns: geo = "http://www.w3.org/2003/01/geo/wgs84_pos#"> 37.37 </geo: lat>
<Geo: long xmlns: geo = "http://www.w3.org/2003/01/geo/wgs84_pos#">-122.04 </geo: long>
<Link>
Bytes
</Link>
<PubDate> Wed, 27 May 2015 pm PDT </pubDate>
<Yweather: condition xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "34" date = "Wed, 27 May 2015 pm PDT" temp = "15" text = "Fair"/>
<Description>
<! [CDATA [
<br/> <B> Current Conditions: </B> <br/> Fair, 15 C <BR/> <B> Forecast: </B> <BR/> Wed-Partly Cloudy. high: 21 Low: 12 <br/> Thu-AM Clouds/PM Sun. high: 23 Low: 12 <br/> Fri-AM Clouds/PM Sun. high: 24 Low: 13 <br/> Sat-AM Clouds/PM Sun. high: 24 Low: 13 <br/> Sun-AM Clouds/PM Sun. high: 22 Low: 14 <br/> <a href = "http://us.rd.yaho Success "> Full Forecast at Yahoo! Weather </a> <BR/> (provided by <a href = "http://www.weather.com"> The Weather Channel </a>) <br/>
]>
</Description>
<Yweather: forecast xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "29" date = "27 May 2015" day = "Wed" high = "21" low = "12" text = "Partly Cloudy"/>
<Yweather: forecast xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "30" date = "28 May 2015" day = "Thu" high = "23" low = "12" text = "AM Clouds/PM Sun "/>
<Yweather: forecast xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "30" date = "29 May 2015" day = "Fri" high = "24" low = "13" text = "AM Clouds/PM Sun "/>
<Yweather: forecast xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "30" date = "30 May 2015" day = "Sat" high = "24" low = "13" text = "AM Clouds/PM Sun "/>
<Yweather: forecast xmlns: yweather = "http://xml.weather.yahoo.com/ns/rss/1.0" code = "30" date = "31 May 2015" day = "Sun" high = "22" low = "14" text = "AM Clouds/PM Sun "/>
<Guid isPermaLink = "false"> USCA1116_2015_05_31_7_00_PDT </guid>
</Item>
</Channel>
</Results>
</Query>
<! -- Total: 22 -->




Note:
The parameters after the url are set to the returned data type, json or xml


In this way, we can get the weather returned in degrees Celsius.
Note that there is a code in the return value of the weather, which represents various weather types, such as storms, tornado, and hail.






Code and its corresponding weather status:


0 tornado
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
9 drizzle
10 freezing rain
11 showers
12 showers
13 snow flurries
14 light snow showers
15 blowing snow
16 snow
17 hail
18 sleet
19 dust
20 foggy
21 haze
22 smoky
23 blustery
24 windy
25 cold
26 cloudy
27 mostly cloudy (night)
28 mostly cloudy (day)
29 partly cloudy (night)
30 partly cloudy (day)
31 clear (night)
32 sunny
33 fair (night)
34 fair (day)
35 mixed rain and hail
36 hot
37 isolated thunderstorms
38 scattered thunderstorms
39 scattered thunderstorms
40 scattered showers
41 heavy snow
42 scattered snow showers
43 heavy snow
44 partly cloudy
45 thundershowers
46 snow showers
47 isolated thundershowers
3200 not available

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.