Google Autocomplete API

Google Autocomplete API allows you to get suggestions for a keyword. The API is accessed through the following endpoint: /search?engine=google_autocomplete. A user may query the following: https://serpapi.com/search?engine=google_autocomplete utilizing a GET request. Head to the playground for a live and interactive demo.

API Parameters

Search Query

q

Required

Parameter defines the search query. A query that would be used to provide completion options.

Localization

gl

Optional

Parameter defines the country to use for the Google search. It's a two-letter country code. (e.g., us for the United States, uk for United Kingdom, or fr for France) Head to the Google countries for a full list of supported Google countries.

hl

Optional

Parameter defines the language to use for the Google search. It's a two-letter lan guage code. (e.g., en for English, es for Spanish, or fr for French) Head to the Google languages for a full list of supported Google languages.

Advanced Autocomplete Parameters

cp

Optional

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|.

client

Optional

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

Serpapi Parameters

engine

Required

Set parameter to google_autocomplete to use the Google Autocomplete API engine.

no_cache

Optional

Parameter will force SerpApi to fetch the Google Autocomplete results even if a cached version is already present. A cache is served only if the query and all parameters are exactly the same. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month. It can be set to false (default) to allow results from the cache, or true to disallow results from the cache. no_cache and async parameters should not be used together.

async

Optional

Parameter defines the way you want to submit your search to SerpApi. It can be set to false (default) to open an HTTP connection and keep it open until you got your search results, or true to just submit your search to SerpApi and retrieve them later. In this case, you'll need to use our Searches Archive API to retrieve your results. async and no_cache parameters should not be used together.

api_key

Required

Parameter defines the SerpApi private key to use.

output

Optional

Parameter defines the final output you want. It can be set to json (default) to get a structured JSON of the results, or html to get the raw html retrieved.

API Results

JSON Results

JSON output includes structured data for suggestions - list of completions for provided keyword. chrome and chrome-omni clients also have omnibox related metadata - suggesttype, verbatim_relevance, clientdata.

A search status is accessible through search_metadata.status. It flows this way: Processing -> Success || Error. If a search has failed, error will contain an error message. search_metadata.id is the search ID inside SerpApi.

HTML Results

This API does not have html response, just a text. search_metadata.prettify_html_file contains prettified version of result. It is displayed in playground.

Example with q: coffee parameter

Example with q: coffee parameter

JSON Example

{
  "search_metadata": {
    "id": "605881c3de9834001cb9a014",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/e577b8c1681b6153/605881c3de9834001cb9a014.json",
    "created_at": "2021-03-22 11:38:43 UTC",
    "processed_at": "2021-03-22 11:38:44 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=coffee&gl=us&hl=en&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/e577b8c1681b6153/605881c3de9834001cb9a014.html",
    "prettify_html_file": "https://serpapi.com/searches/e577b8c1681b6153/605881c3de9834001cb9a014.prettify",
    "total_time_taken": 0.26
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "coffee",
    "gl": "us",
    "hl": "en"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "mega millions",
      "relevance": 1250,
      "type": "QUERY"
    },
    {
      "value": "megan fox",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "megan thee stallion",
      "relevance": 600,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 886
}

Example with q: t scott and cp: 1

cp param can be used to refine completion. It stands for "cursor pointer". In this case it would be set to 1 meaning cursor would take place right after first "t" t| scott
Example with q: t scott and cp: 1

JSON Example

{
  "search_metadata": {
    "id": "605882f5de98340020c8e942",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/ee108fda921ed872/605882f5de98340020c8e942.json",
    "created_at": "2021-03-22 11:43:49 UTC",
    "processed_at": "2021-03-22 11:43:50 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=t+scott&cp=1&gl=us&hl=en&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/ee108fda921ed872/605882f5de98340020c8e942.html",
    "prettify_html_file": "https://serpapi.com/searches/ee108fda921ed872/605882f5de98340020c8e942.prettify",
    "total_time_taken": 1.30
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "t scott",
    "cp": "1",
    "gl": "us",
    "hl": "en"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "travis scott",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "travis scott burger",
      "relevance": 600,
      "type": "QUERY"
    },
    {
      "value": "tim scott",
      "relevance": 555,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 851
}

Example with q: t scott and cp: 7

cp param can be used to refine completion. It stands for "cursor pointer". In this case it would be set to 7 meaning cursor would take place after the last "t" t scott|
Example with q: t scott and cp: 7

JSON Example

{
  "search_metadata": {
    "id": "60588431de9834001e2a3d72",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/9071926fbf9dad59/60588431de9834001e2a3d72.json",
    "created_at": "2021-03-22 11:49:05 UTC",
    "processed_at": "2021-03-22 11:49:05 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=t+scott&cp=7&gl=us&hl=en&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/9071926fbf9dad59/60588431de9834001e2a3d72.html",
    "prettify_html_file": "https://serpapi.com/searches/9071926fbf9dad59/60588431de9834001e2a3d72.prettify",
    "total_time_taken": 1.03
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "t scott",
    "cp": "7",
    "gl": "us",
    "hl": "en"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "t scott jones",
      "relevance": 1250,
      "type": "QUERY"
    },
    {
      "value": "t scott law",
      "relevance": 700,
      "type": "QUERY"
    },
    {
      "value": "t scott construction",
      "relevance": 601,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 1300
}

Example with q: pewdiepie and client: chrome

Changing client param might affect completion results. Here is example for chrome.
Example with q: pewdiepie and client: chrome

JSON Example

{
  "search_metadata": {
    "id": "60588593de9834001e2a3d73",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/17723d4e141789e0/60588593de9834001e2a3d73.json",
    "created_at": "2021-03-22 11:54:59 UTC",
    "processed_at": "2021-03-22 11:54:59 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=pewdiepie&gl=us&hl=en&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/17723d4e141789e0/60588593de9834001e2a3d73.html",
    "prettify_html_file": "https://serpapi.com/searches/17723d4e141789e0/60588593de9834001e2a3d73.prettify",
    "total_time_taken": 1.15
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "pewdiepie",
    "gl": "us",
    "hl": "en",
    "client": "chrome"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "pewdiepie net worth",
      "relevance": 1050,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie merch",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie chair",
      "relevance": 600,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 1300
}

Example with q: pewdiepie and client: safari

Changing client param might affect completion results. Here is example for safari.
Example with q: pewdiepie and client: safari

JSON Example

{
  "search_metadata": {
    "id": "60588679de9834001e2a3d74",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/1909edfac7e1512d/60588679de9834001e2a3d74.json",
    "created_at": "2021-03-22 11:58:49 UTC",
    "processed_at": "2021-03-22 11:58:49 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=pewdiepie&gl=us&hl=en&client=safari",
    "raw_html_file": "https://serpapi.com/searches/1909edfac7e1512d/60588679de9834001e2a3d74.html",
    "prettify_html_file": "https://serpapi.com/searches/1909edfac7e1512d/60588679de9834001e2a3d74.prettify",
    "total_time_taken": 1.13
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "pewdiepie",
    "gl": "us",
    "hl": "en",
    "client": "safari"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "pewdiepie net worth",
      "relevance": 1050,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie merch",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie chair",
      "relevance": 600,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 1300
}

Example with q: pewdiepie and gl: au

Changing gl param affects completion results. Here is example for au.
Example with q: pewdiepie and gl: au

JSON Example

{
  "search_metadata": {
    "id": "6058874ede98340020c8e943",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/bd1194ee7b29e346/6058874ede98340020c8e943.json",
    "created_at": "2021-03-22 12:02:22 UTC",
    "processed_at": "2021-03-22 12:02:22 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=pewdiepie&gl=au&hl=en&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/bd1194ee7b29e346/6058874ede98340020c8e943.html",
    "prettify_html_file": "https://serpapi.com/searches/bd1194ee7b29e346/6058874ede98340020c8e943.prettify",
    "total_time_taken": 1.21
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "pewdiepie",
    "gl": "au",
    "hl": "en",
    "client": "chrome"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "pewdiepie net worth",
      "relevance": 1100,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie sub count",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie merch",
      "relevance": 600,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 1300
}

Example with q: pewdiepie and hl: ja

Changing hl affects completion results in terms of language used.
Example with q: pewdiepie and hl: ja

JSON Example

{
  "search_metadata": {
    "id": "6058882ede9834002292ab3a",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/5c2fb9ce14ffbd58/6058882ede9834002292ab3a.json",
    "created_at": "2021-03-22 12:06:06 UTC",
    "processed_at": "2021-03-22 12:06:06 UTC",
    "google_autocomplete_url": "https://www.google.com/complete/search?q=pewdiepie&hl=ja&client=chrome",
    "raw_html_file": "https://serpapi.com/searches/5c2fb9ce14ffbd58/6058882ede9834002292ab3a.html",
    "prettify_html_file": "https://serpapi.com/searches/5c2fb9ce14ffbd58/6058882ede9834002292ab3a.prettify",
    "total_time_taken": 1.04
  },
  "search_parameters": {
    "engine": "google_autocomplete",
    "q": "pewdiepie",
    "hl": "ja",
    "client": "chrome"
  },
  "search_information": {
    "autocomplete_results_state": "Showing completion results."
  },
  "suggestions": [
    {
      "value": "pewdiepie net worth",
      "relevance": 1000,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie なぜ人気",
      "relevance": 601,
      "type": "QUERY"
    },
    {
      "value": "pewdiepie 年収",
      "relevance": 600,
      "type": "QUERY"
    },
    ...
  ],
  "verbatim_relevance": 1290
}