views:

21

answers:

1

so i want to experiment with Google's search suggestion feature for word/phrase completion. I.e. stick the functionality of typing a search on their home page into a text editor for starters.

is it possible to request these Google search suggestions with their REST API? Or somehow?

+2  A: 

You could use one of the following URLs to get search suggestions from Google:

1. URL used by the suggestion box on the home page

http://www.google.com/complete/search?hl=en&js=true&qu=sugge

The query part is the qu parameter. A sample response would be:

window.google.ac.h(["sugge",[["suggest","200,000,000 results","0"],["suggestion box","27,500,000 results","1"],["suggestion","84,300,000 results","2"],["suggest friends on facebook","73,100,000 results","3"],["suggested calorie intake","1,940,000 results","4"],["suggestive","12,400,000 results","5"],["suggestion boxes","997,000 results","6"],["suggested weight for height and age","72,600,000 results","7"],["suggest synonym","2,490,000 results","8"],["suggestopedia","79,300 results","9"]]])

2. URL used by the Google toolbar

http://toolbarqueries.google.com/complete/search?q=sugge&output=toolbar&hl=en

The query is obviously the q parameter. This has the advantage of returning XML data, that is easier and more portable in terms of parsing the result:

<?xml version="1.0"?>
<toplevel>
    <CompleteSuggestion><suggestion data="suggest"/><num_queries int="200000000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggestion box"/><num_queries int="27500000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggestion"/><num_queries int="84300000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggest friends on facebook"/><num_queries int="73100000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggested calorie intake"/><num_queries int="1940000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggestive"/><num_queries int="12400000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggestion boxes"/><num_queries int="997000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggested weight for height and age"/><num_queries int="72600000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggest synonym"/><num_queries int="2490000"/></CompleteSuggestion>
    <CompleteSuggestion><suggestion data="suggestopedia"/><num_queries int="79300"/></CompleteSuggestion>
</toplevel>
the_void