Free weather forecast api--Google, Yahoo, Central Meteorological Observatory

Source: Internet
Author: User
Tags yahoo weather api

      The Google Weather API only supports U.S. regions using ZIP codes for queries, such as:
http://www.google.com/ig/api?hl=zh-cn&weather=94043
(94043 for Mountain View, California, United States ZIP code)
In addition to the United States outside the region need to use latitude and longitude coordinates as a parameter to run the Google Weather API, such as:
http://www.google.com/ig/api?hl=zh-cn&weather=,,, 30670000,104019996
(30670000,104019996 is Chengdu, latitude and longitude coordinates of mainland China)


Of course, may also pass the city name Hanyu Pinyin to inquire, for example: Below is the weather of Beijing


Http://www.google.com/ig/api?weather=Beijing



For other regions latitude and longitude coordinates, can be provided through the Google API country code list and corresponding city latitude and longitude coordinates list can be queried, the following is the Google API provides query parameters:
Http://www.google.com/ig/countries?output=xml&hl=zh-cn
(Check the code of all countries supported by Google and display it in ZH-CN Chinese)
Http://www.google.com/ig/cities?output=xml&hl=zh-cn&country=cn

Google has opened a weather API, which is very useful.


Use ZIP code (US)
http://www.google.com/ig/api?hl=zh-cn&weather=94043 (Mountain View, California)


Use latitude and longitude coordinates
http://www.google.com/ig/api?hl=zh-cn&weather=,,, 30670000,104019996 (Chengdu)


Use the city name of the pass
HTTP://WWW.GOOGLE.COM/IG/API?WEATHER=BEIJING&HL=ZH-CN (Beijing)
HTTP://WWW.GOOGLE.COM/IG/API?WEATHER=OSAKA&HL=ZH-CN (Osaka)
Or
Http://www.google.com/ig/api?weather=Beijing&hl=zh (Beijing)
Http://www.google.com/ig/api?weather=Osaka&hl=ja (Osaka)


What countries and cities can I find? Google also provides an interface. The returned type can also be specified according to the output parameters.
Find Country HTTP://WWW.GOOGLE.COM/IG/COUNTRIES?OUTPUT=XML&HL=ZH-CN (return XML)
Find City HTTP://WWW.GOOGLE.COM/IG/CITIES?HL=ZH-CN&COUNTRY=CN (back to JSON)


With this data, it is not difficult to add a weather forecast to your application.


Google's weather forecast API. The advantage is the ability to get direct access to countries and cities that support query weather. and can forecast 4 days weather, support latitude and longitude query weather (this can use GPS to do the application).

The downside is amazing: there are fewer Chinese cities to support. Details of what can be queried through HTTP://WWW.GOOGLE.COM/IG/CITIES?HL=ZH-CN&COUNTRY=CN.





--------------------------------------------------------------------------------------------------------------- -------------------


Yahoo Weather API

The URL for Yahoo weather forecast is

HTTP://WEATHER.YAHOOAPIS.COM/FORECASTRSS?W=2151330&U=C (returns XML data)

Talk about the meaning of the number of participants:

The Woeid of the corresponding places in the Yahoo database, such as Beijing's Woeid is 2151330, can now be used to replace W with the number of P, but the official or recommended W, it seems that P is planned to be canceled. The parameter u is used to determine the unit of temperature (C is degree F is Fahrenheit). For China's (no foreign) weather query, Yahoo relative to the location can be found or the content of the forecast is relatively full.

Get Address number

The address number must be a woeid, and you can check the address number you need via Yahoo's weather forecast homepage. This number is in
The URL of the city weather page you want. You can also enter your zip code query Woeid in the home page. For example, if you want to inquire about the weather conditions in Guangzhou, the URL of the city's weather page is
Http://weather.yahooapis.com/forecastrss?p=CHXX0037&u=c, so its woeid is 0037.

here is an online search for Yahoo weather forecast City code: Yahoo weather forecast City Code

yahoo weather Developer: http://developer.yahoo.com/weather/


Strengths: Also did not find what very special strengths. It's just that the city code I've collected feels a whole (not really checked out after all).

Cons: Only two days of weather can be predicted


Add:

The Woeid can be obtained through the following URLs:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3d%22shanghai%22& Diagnostics=true

Replace the city name in the URL, and the query results in Woeid is the code.
If you want to query directly can be landed http://developer.yahoo.com/yql/console/query geo.places can be obtained. The Yahoo database is also able to find other interesting things.

Get Woeid BR style= "font-family: ' Lucida Grande '; font-size:12px ">http://query.yahooapis.com/v1/public/yql?q=select * from Flickr.places where lon=%f and Lat=%f and accuracy=6 (no validation)

Http://query.yahooapis.com/v1/public/yql?q=select * from Geo.places where lon=%f and Lat=%f and accuracy=6(no validation )

--------------------------------------------------------------------------------------------------------------- ------------------------------



The last introduction is the API of the Central Meteorological Observatory:

City weather conditions are available based on the following interfaces
Http://www.weather.com.cn/data/sk/101010100.html
Http://www.weather.com.cn/data/cityinfo/101010100.html
Http://m.weather.com.cn/data/101010100.html

The JSON data is returned. The data returned from the above three URLs is not the same. Try it out in detail. The data is very full, 101010100 is the city code of Beijing, so still need city code. Provide a very incomplete city code. I searched very long to get. There are about 20 provinces around. The area can be detailed to the county seat. Central Meteorological Observatory City Code (incomplete) rayyu1989 share of the more comprehensive apihttp://dl.vmall.com/c0diylrr6a


Central Meteorological Observatory City code: http://blog.csdn.net/ztp800201/article/details/10169863


Strengths: Very specific information. I like this kind of data very much.


Cons: City code not all .... If anyone has an entire city code, please give me a copy.


ps: Suppose you want to see the weather data format or the detailed type. You can see the data directly by copying the link to the browser to run.

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.