Google’s Weather & other Secret API’s

A very simple means of extracting weather information for inclusion in your website is via a very unknown Google weather API. The API will return weather in a very digestible XML format that you can easily parse for inclusion on any page.

The API requires no key and is seemingly unsupported.

The Code

<?php
  $xml = simplexml_load_file('http://www.google.com/ig/api?weather=ADDRESS');
  $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");
  echo $information[0]->attributes();
?>

A Sample Application for Sydney, Australia

<?php
  $xml = simplexml_load_file('http://www.google.com/ig/api?weather=Sydney,Australia');
  $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");
  echo $information[0]->attributes();
?>

Note that I’ve simply replaced ADDRESS with a city and state (although you can use local data as well). You can also replace with a US zip code. The API will return data that looks like this.

Interestingly, the icon data returned points to image files used by the iGoogle front page.

Other Secret API’s

I shouldn’t use the word secret – but they are very much an unknown. Google has a bunch of API’s accessible without a key or any kind of registration; and they return funky data that you can easily incorporate into your website or application.

Given that they’re not widely publicised by Google (and somebody please correct me if I’m wrong), they seemingly come without support, warranty or any kind of guarantee. There’s no mention of them on the Google website.

Google’s Stock API

http://www.google.com/ig/api?stock=VBA will return the latest stock information for Virgin Blue Airlines. http://www.google.com/ig/api?stock=GOOG will return the latest data for Google. Data is returned in an XML format that can be easily fashioned for inclusion on your website.

Other Google API’s

Google already returns its news via a digestible RSS feed, but the News API returns it in a more usable format (http://www.google.com/ig/api?news). There seems to be an API for movies although I haven’t quite figured it out (http://www.google.com/ig/api?movies=90210).

Interesting.

First Name:
Your Email Address:
 


If you liked this article, you may also like:

  1. Country, State & City from Google’s Geocoding API
  2. Generate QR Codes on Your Website or WordPress Post with Google Chart Tools
  3. Google Chart WordPress Shortcode
  4. Add Your Latest Google Plus Post(s) to Your WordPress Blog (or Generate a Google+ RSS Feed)
  5. Retrieve Images from the (Depreciated) Google Images API
About Marty

is a passionate web developer from Sydney, Australia. He owns about 600 websites and makes a healthy living from working the web. As a day job, he works as a pilot for an international airline. Follow Marty on Twitter or Google+.

Trackbacks

  1. [...] om inte det var nog så har Google även ett odokumenterat väder API, testa tex http://www.google.com/ig/api?weather=Helsingborg. Ingen API nyckel krävs och eftersom [...]

Please leave a comment or question!

*