Google Suggestions API

Extract Google Suggestions API Data for SEO Insights with Python

Estimated Read Time: 5 minute(s)
Common Topics: data, offset, collars, google, enlighter

One of the main tenets of SEO is understanding the search climate for the keywords you are targeting: the trends, what people are searching for, and the relative search volume. Those insights help generate targeted keyword ideas. An often-overlooked source is the Google Suggestions API — it taps Google’s search autocomplete feature.

You can call that feature outside Google’s search bar to return autocomplete suggestions based on real user queries. These suggestions reveal audience intent and surface additional keyword opportunities to target.

Surprisingly, this is one of the simplest “APIs” to use: no keys, no OAuth, no complex flows — just a few parameters. It feels like a lightly documented Google side project. Let’s dig in with Python while it’s still available.

Key Points

  1. One of the main tenets of SEO is understanding the search climate for the keywords you are targeting.
  2. Google Suggestions is an often overlooked API that taps into Google‘s search autocomplete feature.
  3. It is one of the easiest APIs to use with no keys, no OAuth, no multiple calls, and few parameters to configure.
  4. Requires Python 3 and access to a Linux installation (or Google Colab).
  5. Install the fake_useragent module for the call header to ward off light abuse detection.
  6. Import the requests, JSON, and user_agent modules.
  7. Assign the keyword/keyphrase to a variable with spaces replaced with a plus (+) character or %20.
  8. Use the URL http://suggestqueries.google.com/complete/search?output=firefox&q= + keyword to make the call.
  9. Create a user agent for the API call to use in the header.
  10. The response will be in JSON (or XML if the output is set to toolbar).
  11. Output can include extra data like google:clientdata, google:suggestrelevance, google:suggesttype and google:verbatimrelevance.
  12. Use the response to output cleanly.
  13. For deeper analysis, extend the script to go 3 levels deep for each initial single result and then count the frequency.

Requirements and Assumptions

  • Python 3 is installed and basic Python syntax is understood
  • Access to a Linux installation (Ubuntu recommended) or Google Colab

Starting the Script

First, install the fake_useragent module to use in the request header. Using a realistic user-agent can help reduce lightweight abuse detection. The API has no documented usage limits; Google’s defenses can still block excessive requests, potentially causing temporary or permanent IP blocks. If you’re using Google Colab, prefix the pip3 command with an exclamation mark: !pip3.

pip3 install fake_useragent

Next, import the requests module to make the API call, import json to parse the response, and import the user_agent module you installed.

import requests
import json
from fake_useragent import UserAgent

Assign the Keyword

Assign your keyword or keyphrase to a variable — this is the text Google’s suggestions will use. Because the variable goes into a URL, replace spaces with a plus (+) character or use %20.

keyword = "dog collars"
keyword.replace(" ", "+")

Build the Google Suggestions API Call

The base URL is http://suggestqueries.google.com/complete/search.

Key parameters:

  • client or output — what client to mask as (firefox, chrome, toolbar). This controls the output format and whether extra fields are included. Toolbar returns XML; Firefox and Chrome return JSON. Chrome can include additional fields.
  • hl — country or locale code (us, uk, fr…)
  • gl — language/region (en, es, fr…)
  • q — the query

We’ll keep it simple: omit hl and gl, and set output=firefox to receive JSON.

url = "http://suggestqueries.google.com/complete/search?output=firefox&q=" + keyword

Make the Google Suggestions API Call

Build a user agent for the request, then send the GET to the URL above with that user-agent and assign the result to response. verify=False disables TLS certificate verification; this can be useful for untrusted endpoints but may cause issues with some servers, so it’s disabled here.

ua = UserAgent()
headers = {"user-agent": ua.chrome}
response = requests.get(url, headers=headers, verify=False)

Process the Google Suggestions API Response

If you choose output=firefox you receive a compact JSON structure like this:

["dog collars",["dog collars","dog collars amazon","dog collars etsy","dog collars and leashes","dog collars with name","dog collars personalized","dog collars leather","dog collars near me","dog collars walmart","dog collars for large dogs"],[],{"google:suggestsubtypes":[[433],[],[],[],[],[],[],[],[],[]]}]

Using output=chrome returns JSON with extra fields such as google:clientdata, google:suggestrelevance, google:suggesttype, and google:verbatimrelevance. The additional fields can be useful, but their interpretation varies. If anyone has insight on those, let me know!

["dog collars",["dog collars amazon","dog collars with name","dog collars etsy","dog collars and leashes","dog collars personalized","dog collars leather","dog collars near me","dog collars walmart"],["","","","","","","",""],[],{"google:clientdata":{"bpc":false,"tlw":false},"google:suggestrelevance":[601,600,555,554,553,552,551,550],"google:suggesttype":["QUERY","QUERY","QUERY","QUERY","QUERY","QUERY","QUERY","QUERY"],"google:verbatimrelevance":1300}]

Output the Response

Load the JSON response into a Python variable and iterate over the suggestion list to print each suggestion cleanly.

suggestions = json.loads(response.text)
for word in suggestions[1]:
  print(word)

Example output

google suggestions

Extra Resources

Colab Notebook
https://colab.research.google.com/drive/18Nta_IO3pi-iu5eYxgGIfjjZ63PIJuKV

Inspiration
https://github.com/Leszek-Sieminski
https://leszeksieminski.me/r/keyword-exploration-googlesuggestqueriesr/

Extend the script
Go 3 levels deep for each initial single result and then count the frequency. Awesome!
https://github.com/omkom-web/scripts-seo/blob/master/gsuggest-distrib.py

Conclusion

With this approach you can programmatically retrieve Google suggestions for content and keyword ideas. Try it out and adapt the script to your workflow. Follow me on Twitter and share your applications and ideas!

FAQ

What are Google Suggestions?

Google Suggestions is an API that taps into Google‘s search autocomplete feature and returns a collection of autocomplete suggestions based on what other people are searching.

What are some of the parameters needed to make the Google Suggestions API call?

The parameters that are needed are client or output, hl, gl, and q. Client or output determines the format of the output and if you get extra data. HL and GL determine the country and language to use. Q is the query.

What is the base URL for the Google Suggestions API call?

The base URL for the Google Suggestions API call is http://suggestqueries.google.com/complete/search.

What is the example output for the Google Suggestions API call?

The example output for the Google Suggestions API call is:dog collars“,[“dog collars amazon“,”dog collars with name“,”dog collars etsy“,”dog collars and leashes“,”dog collars personalized“,”dog collars leather“,”dog collars near me“,”dog collars walmart].

Greg Bernhardt
Follow me