About Autocomplete API

This API allows you to get suggestions for a keyword from what would be the main page of google and provides a bit different results than related_searches (found on other API’s we offer).

This blog entry will highlight and explore the different parameters and the data sets found in JSON responses with the Google Autocomplete API.

Playground

If you navigate to the demonstration playground area that SerpApi provides for users:

SerpApi Playground - SerpApi
Test SerpApi’s Google Search, Google Maps, YouTube, Bing, Walmart, Ebay, Baidu, Yandex and more APIs for free in the interactive playground!

You can see the full breakdown and visualized potential parameters, the HTML scraped and the JSON response.

Let’s take a look at the Advanced Parameters, as we have gone over the localization before in other blogs:

Geographic Location and Localization parameters on SerpApi’s Google Search API
SerpApi’s Google Organic Search API has many parameters to create a very specific request to scrape data. In this walk-through we will talk…

In the advanced parameters we have:cp and client for potential parameters.

When you hover over the ? near the parameter names, we see the breakdown.

For cp it states:

Cursor pointer defines the position of cursor for the query provided, position starts from 0 which is a case where cursor is placed before the query |query. If not provided acts as cursor is placed in the end of query query|.

For client it states:

Parameter used to define client for autocomplete. List of supported clients.

And this link brings us to the SerpApi page of Supported Google Autocomplete Clients:

So this is an option for the type of browser that would be queried with.

psy-ab is used in when google is opened in google chrome.

safari is used in when google is opened in safari.

firefox is used in when google is opened in firefox.

youtube origin unknown. Returns JSONP.

toolbar origin unknown. Returns XML.

Use Case

Now I went over to the SerpApi Playground and started playing with the white-listed query “coffee” and manipulating the advanced search parameters.

First I wanted to see if there was a significant difference in dataset (I copied only the first 5 results) when I changed the cursor pointer cp parameter from |query to query|

{
   "value":"coffee near me",
   "relevance":950,
   "type":"QUERY"
},
{
   "value":"coffee washington",
   "relevance":601,
   "type":"QUERY"
},
{
   "value":"coffee alexandria va",
   "relevance":600,
   "type":"QUERY"
},
{
   "value":"coffee shops near me",
   "relevance":554,
   "type":"QUERY"
},
{
   "value":"coffee table",
   "relevance":553,
   "type":"QUERY"
}

VS

{
   "value":"coffee mate",
   "relevance":601,
   "type":"QUERY"
},
{
   "value":"coffee break",
   "relevance":600,
   "type":"QUERY"
},
{
   "value":"coffee bread",
   "relevance":555,
   "type":"QUERY"
},
{
   "value":"coffee bar",
   "relevance":554,
   "type":"QUERY"
},
{
   "value":"coffee prince",
   "relevance":553,
   "type":"QUERY"
}

There is a different response. And also within the dataset there is a “relevance” data set.

I wondered where and what the information correlated to. When I checked out the raw_html_file I saw this:

There is a relevance score that is a bit arbitrary to users, but this is how Google ranks and orders the results.Then when switching the client . Here are the top three JSON results.

Chrome:

{
   "value":"coffee near me",
   "relevance":1250,
   "type":"QUERY"
},
{
   "value":"coffee las vegas",
   "relevance":601,
   "type":"QUERY"
},
{
   "value":"coffee henderson nv",
   "relevance":600,
   "type":"QUERY"
}

Chrome-omni:

{
   "value":"coffeeholic",
   "relevance":651,
   "type":"QUERY"
},
{
   "value":"coffee near me",
   "relevance":650,
   "type":"QUERY"
},
{
   "value":"coffee bellevue",
   "relevance":601,
   "type":"QUERY"
}

Safari:

{
   "value":"coffee nearby"
},
{
   "value":"coffee near me"
},
{
   "value":"coffee richmond va"
}

FireFox:

{
   "value":"coffeeshop"
},
{
   "value":"coffeeshop in de buurt"
},
{
   "value":"coffeelicious"
}

Psy-ab:

{
   "value":"coffee<b> near me</b>"
},
{
   "value":"coffee<b> shops near me</b>"
},
{
   "value":"coffee"
}

Youtube:

{
   "value":"coffee near me"
},
{
   "value":"coffee columbus ohio"
},
{
   "value":"coffee dublin ohio"
}

Quite different results and also, the relevancy score was only prevalent in chrome and chrome-omni searches.