What does Google suggest?

Posted on Thursday June 2011

I recently noticed google suggest is a JSONP source, so lets quickly try and consume it. JQuery can handle JSONP easily by appending ?callback=? to the request URL.

From a very brief search it looks like this is an undocumented feature of Google. A bit like the Google weather API.

The codes...

<input type="text" id="suggestText" />
<ul id="suggestions"></ul>

$('#suggestText').change(function() {
         .replace('{0}', $(this).val()), 
         function(data) {
             $('#suggestions li').remove();
             $.each(data[1], function(key, val) {
                 $('#suggestions').append('<li>' + val[0] + '</li>');

The JSON is similiar to:

    ["test internet speed","","1"],
    ["test my speed","","3"],
    ["testicular cancer","","4"],
    ["test flash","","6"],
    ["test drive unlimited 2","","8"],