How to use Google, Bing and Amazon Autocomplete APIs?

Keyword Suggestions using the Autosuggest Features of Search Engines are very powerful. Your Keyword Research gets even more powerful when you automate the keyword extraction process by calling the autocomplete APIs using a script language like Python. Of course you can also use our free online autosuggest keyword tool if you do not want to code at all.
In this post we share how to use the different autosuggest endpoints of Google, Bing and Amazon.

How to use the Google Autosuggest API

You can check how you can use Google autosuggest endpoint with this easy to use python block

import json
import requests

def makeGoogleRequest(query, language, country, context):
    URL="http://suggestqueries.google.com/complete/search"
    PARAMS = {"client": "firefox",
            "hl": language,
            "q": query,
            "gl": country,
            "ds": context}
    headers = {'User-agent':'Mozilla/5.0'}
    response = requests.get(URL, params=PARAMS, headers=headers)
    if response.status_code == 200:
        suggestedSearches = json.loads(response.content.decode('utf-8'))[1]
        return suggestedSearches
    else:
        return ""

We need to define four parameters:

  • query (q): the keyword that you need to search about its autocomplete. For example loreal.
  • language (hl): autocomplete results language. For example en, de, tr. For more language codes you can visit Google supported language page.
  • country (gl): autocomplete results country. For example US, DE, TR. For more country codes you can visit Google supported country code page.
  • context (ds): which type of google autosuggestion source you need. For Web as source use web, YouTube as source use yt, Products as source use sh, and News as source use n.

When you need to use it just call the function with parameters and all thing will be OK. Let’s try to call Google autocomplete from Products source for loreal keyword.

>> makeGoogleRequest("loreal","en","DE","sh")
['loreal shampoo',
 'loreal',
 'loreal hair color',
 'loreal hair colour',
 'loreal serum',
 'loreal mascara',
 'loreal foundation',
 'loreal infallible foundation',
 'loreal hair serum',
 'loreal professional shampoo']

Let’s give you an amazing hint to increase your autocomplete results. For each keyword you want to search about its autosuggestion add space then character to it (a-z,0-9). For example for loreal keyword: loreal a, loreal b,…….., loreal z, loreal 0, loreal 1, ………., loreal 9.

>> makeGoogleRequest("loreal a","en","DE","sh")
['loreal anti dandruff shampoo',
 'loreal absolut repair shampoo',
 'loreal absolut repair',
 'loreal anti aging cream',
 "l'oreal age perfect",
 'loreal absolut repair mask',
 "l'oreal age perfect golden age",
 'loreal absolut repair oil',
 'loreal anti hair fall shampoo',
 'loreal ash supreme']

>> makeGoogleRequest("loreal b","en","DE","sh")
['loreal bb cream green',
 'loreal bb cream',
 'loreal bleach',
 'loreal blush',
 'loreal bb cream anti redness',
 'loreal beard oil',
 'loreal black hair colour',
 'loreal black hair dye',
 'loreal blonde hair dye',
 'loreal brown hair colour']


>> makeGoogleRequest("loreal 1","en","DE","sh")
["l'oreal 173",
 'loreal 13 shade',
 'loreal 12.11 hair color',
 "l'oreal 10 in 1",
 'loreal 12.1 hair color',
 'loreal 11.11',
 'loreal 1 litre shampoo',
 'loreal 121 lipstick',
 'loreal 129',
 "l'oreal 181"]

As you see by using this hint the result for each keyword will be about 350 instead of just 10 result.

Also you can use it directly through your web browser using this link suggestqueries.google.com/complete/search with the parameters for example http://suggestqueries.google.com/complete/search?client=firefox&hl=en&gl=DE&ds=sh&q=loreal

How to use the Bing Autosuggest API

You can check how you can use Bing autosuggest endpoint with this easy to use python block

import requests
import xmltodict

def makeBingRequest(query,market):
    URL = "https://api.bing.com/qsml.aspx"
    PARAMS = {"Market":market,
            "query":query}
    headers = {'User-agent':'Mozilla/5.0'}
    response = requests.get(URL, params=PARAMS, headers=headers)
    if response.status_code == 200:
        obj = None
        obj = xmltodict.parse(response.content)
        suggestList = []
        if obj['SearchSuggestion']['Section'] != None:
            suggests = obj['SearchSuggestion']['Section']['Item']
            if len(suggests)==1:
                suggests = [suggests]
            for suggest in suggests:
                _s = suggest['Text']
                suggestList.append(_s)
        return suggestList
    else:
        return ""

We need to define two parameters:

  • query : the keyword that you need to search about its autocomplete. For example loreal.
  • Market:  market code value that the results will return from it. For example de-DE for Germany country , German language and en-US for United States country , English language. For more market codes you can visit market and language codes page.

When you need to use it just call the function with parameters and all thing will be OK. Let’s try to call Bing autocomplete for loreal keyword.

>> makeBingRequest("loreal","en-US")
['loreal',
 'loreal paris',
 "l'oreal lipstick colors",
 "l'oreal lipstick",
 "l'oreal mascara",
 'loreal hair colors',
 'loreal shampoo',
 "l'oreal preference",
 "l'oreal hair color",
 "l'oreal foundation"]

Feel free to use the previous amazing hint with Bing autosuggest too.

>> makeBingRequest("loreal a","en-US")
['loreal annualpdf',
 "l'oreal age perfect",
 "l'oreal access",
 'loreal absolut repair',
 'loreal anti aging products',
 "l'oreal ad",
 "l'oreal age perfect foundation",
 "l'oreal ash blonde",
 'loreal annual report 2020',
 "l'oreal app"]

>> makeBingRequest("loreal b","en-US")
["l'oreal brands",
 "l'oreal bb cream",
 'loreal blush',
 "l'oreal brow",
 'loreal blonde shampoo',
 "l'oreal bleach",
 "l'oreal bronzer",
 "l'oreal bb cream green"]


>> makeBingRequest("loreal 1","en-US")
['loreal 10 in 1',
 'loreal 10.21',
 'loreal 129',
 'loreal 173 lipstick',
 'loreal 104',
 "l'oreal 10k",
 'loreal 18',
 "l'oreal 102"]

>> makeBingRequest("loreal 2","en-US")
['loreal 2005',
 'loreal 2021',
 'loreal 2020 annual report',
 'loreal 235',
 'loreal 24h fresh wear foundation',
 'loreal 2 in 1 mascara',
 'loreal 2000 calorie',
 'loreal 2 step mascara']

As you see this hint is worked for Bing too then the result for each keyword will be about 350 instead of just 10 result.

Also you can use it directly through your web browser using this link api.bing.com/qsml.aspx with the parameters for example https://api.bing.com/qsml.aspx?Market=en-US&query=loreal

How to use the Amazon Autosuggest API

You can check how you can use Amazon autosuggest endpoint with this easy to use python block

import json
import requests

def makeAmazonRequest(query):
    URL="https://completion.amazon.com/search/complete"
    PARAMS = {"client": "amazon-search-ui",
            "search-alias": "aps",
            "mkt": 1,
            "q": query,
            }
    headers = {'User-agent':'Mozilla/5.0'}
    response = requests.get(URL, params=PARAMS, headers=headers)
    if response.status_code == 200:
        suggestedSearches = json.loads(response.content.decode('utf-8'))[1]
        return suggestedSearches
    else:
        return ""

We just need to define query (q) parameter which is keyword that you need to search about its autocomplete. For example loreal.

When you need to use it just call the function with query (q) parameter and all thing will be OK. Let’s try to call Amazon autocomplete for loreal keyword.

>> makeAmazonRequest("loreal")
['loreal revitalift',
 'loreal mascara',
 'loreal hair color',
 'loreal',
 'loreal true match hyaluronic tinted serum',
 'loreal infallible foundation',
 'loreal shampoo and conditioner',
 'loreal telescopic mascara',
 'loreal bb cream green',
 'loreal root cover up spray']

Feel free to use the previous amazing hint with Amazon autosuggest too.

>> makeAmazonRequest("loreal a")
['loreal age perfect',
 'loreal age perfect radiant serum foundation',
 'loreal age perfect night cream',
 'loreal age perfect foundation',
 'loreal absolut repair',
 'loreal age perfect day cream',
 'loreal age perfect moisturizer',
 'loreal age perfect eye renewal eye cream',
 'loreal age perfect cell renewal',
 'loreal air volume mega mascara']

>> makeAmazonRequest("loreal b")
['loreal bb cream green',
 'loreal bb cream',
 'loreal brow stylist definer',
 'loreal blush',
 'loreal brow stylist shape and fill pencil',
 'loreal blow dry it thermal smoother cream',
 'loreal bond strengthening shampoo and conditioner',
 'loreal bronzer',
 'loreal brow pencil',
 'loreal bleach']


>> makeAmazonRequest("loreal 1")
['loreal 10 in 1 spray',
 'loreal 173 lipstick nu impertinent',
 'loreal 10% glycolic acid',
 'loreal 10 in 1',
 'loreal 1.5 pure hyaluronic acid serum',
 'loreal 173 lipstick',
 'loreal 173',
 'loreal 129 lipstick',
 'loreal 106 lipstick',
 'loreal 107 lipstick']

>> makeAmazonRequest("loreal 2")
['loreal 24 hour infallible foundation',
 'polvo infalible loreal 24 horas',
 'base infalible loreal 24 horas',
 'loreal 20 volume developer',
 'loreal 24 hour fresh wear foundation',
 'loreal 24 hour lipstick',
 'loreal 24 hour eyeshadow',
 'loreal 20 volume cream developer',
 'loreal 21 in 1 spray',
 'loreal 2 step lipstick']

As you see this hint is worked for Amazon too then the result for each keyword will be about 350 instead of just 10 result.

Also you can use it directly through your web browser using this link completion.amazon.com/search/complete with the parameters for example https://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q=loreal

Python in PPC / SEO

More Similar Posts

Menu