The top Google API’s you’ve never heard of

Favicons

Google has a super-secret way to extract the favicon from some websites. While I can’t say that it works 100%, it at least displays a generic globe fallback. If you need an easy — if sometimes unreliable — way to pull a website favicon, here’s your URL. Just slap it into an img tag and you’re golden. Here’s an example:

[html light=”1″]
<img src="http://www.google.com/s2/favicons?domain=websitesthatdontsuck.com">
[/html]

which results in:

Weather

Google also has a hidden weather API. It’s undocumented and can only return data in XML format, but it’s also super-easy to figure out what it’s returning. May be good for mocking up a quick weather app or — as Google does — using it for a desktop widget.

To use, send a simple GET request with the city, state or zip code such as this:

[html light=”1″]http://www.google.com/ig/api?weather=Scottsdale,+AZ[/html]

It returns an XML response that’s pretty self-explanatory. You’ll want to parse it out within your application. Here’s an example response (that I slightly truncated for repeated, forecast data)

[xml]
<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
<forecast_information>
<city data="Scottsdale, AZ"/>
<postal_code data="Scottsdale, AZ"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2011-11-09"/>
<current_date_time data="2011-11-09 15:51:00 +0000"/>
<unit_system data="US"/>
</forecast_information>
<current_conditions>
<condition data="Clear"/>
<temp_f data="55"/>
<temp_c data="13"/>
<humidity data="Humidity: 47%"/>
<icon data="/ig/images/weather/sunny.gif"/>
<wind_condition data="Wind: N at 0 mph"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="Sat"/>
<low data="52"/>
<high data="74"/>
<icon data="/ig/images/weather/chance_of_rain.gif"/>
<condition data="Chance of Showers"/>
</forecast_conditions>
</weather>
</xml_api_reply>[/xml]

Predictions

This is a collection of some pretty neat API tools. Google claims you’ll be able to:

  • Detect customer sentiments
  • Figure out movie recommendations based on past viewing
  • Filter Spam
  • And whatever else
  • The concept is that you train the prediction API with some known data. You then provide it some unknown data to compare against the known data. Using this, it can predict an outcome.

    Setting this up will take some work preparing data, uploading it to Google Cloud Storage, training the prediction engine, let alone running the predictions. To get started with this über cool API, head on over to Google Code

    Charts

    The Charts API lets you build — in JavaScript — some really cool looking and interactive charts. Line charts, bar graphs, pie charts, even a fun gas-gauge chart. There are more that have been added by Google and even third parties. Implementation? Fairly simple. Here’s the javascript bits from their hello world chart demo. Head over there for details

    [javascript]
    // Load the Visualization API and the piechart package.
    google.load(‘visualization’, ‘1.0’, {‘packages’:[‘corechart’]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

    // Callback that creates and populates a data table,
    // instantiates the pie chart, passes in the data and
    // draws it.
    function drawChart() {

    // Create the data table.
    var data = new google.visualization.DataTable();
    data.addColumn(‘string’, ‘Topping’);
    data.addColumn(‘number’, ‘Slices’);
    data.addRows([
    [‘Mushrooms’, 3],
    [‘Onions’, 1],
    [‘Olives’, 1],
    [‘Zucchini’, 1],
    [‘Pepperoni’, 2]
    ]);

    // Set chart options
    var options = {‘title’:’How Much Pizza I Ate Last Night’,
    ‘width’:400,
    ‘height’:300};

    // Instantiate and draw our chart, passing in some options.
    var chart = new google.visualization.PieChart(document.getElementById(‘chart_div’));
    chart.draw(data, options);
    }
    [/javascript]

    Google offers tons of APIs that are document and supported, and likely many more that are hidden behind the scenes. Here’s a fun periodic table of the APIs to get you started with their developer products.

    Google's Periodic Table of APIs

    Do you use any Google APIs on your website? Perhaps Maps, search, something funkier? Let us know your favorite in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *