Use Amazon Autocomplete Keyword Expander with Python
Turn seed keywords into Amazon's own search-box autocomplete suggestions across 23 marketplaces. Expand past the usual per-query cap with A-Z/0-9/custom suffixes and recursive re-querying of newly found suggestions.
1. Choose the data you need
Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.
2. Prepare a source-based input
This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.
{
"customSuffixes": [],
"dedupe": true,
"departments": [
"aps"
],
"excludeTerms": [],
"expandAlphabet": false,
"expandBuyerModifiers": false,
"expandComparisons": false,
"expandNumbers": false,
"expandPrefixAlphabet": false,
"expandPrepositions": false,
"expandQuestions": false,
"includeSeed": false,
"includeTerms": [],
"includeWidgets": false,
"keywords": [
"wireless earbuds"
],
"marketplace": "US",
"marketplaces": [],
"maxConcurrency": 1,
"maxDepth": 0,
"maxQueries": 3,
"maxSuggestions": 3,
"maxSuggestionsPerKeyword": 0,
"minWordCount": 0,
"mustContainSeed": false,
"onlyLongTail": false,
"onlyQuestions": false,
"queryMode": "enhanced",
"requestDelayMs": 0,
"resultOrder": "source"
}
Download input.example.json and save your reviewed copy as input.json.
| Field | Type | Required | Description |
|---|---|---|---|
keywords | array | required | One or more seed keywords or phrases to expand into Amazon autocomplete suggestions. |
marketplace | string | optional | Single Amazon marketplace to query. Used when `marketplaces` is empty. |
marketplaces | array | optional | Optional multi-market sweep, e.g. ["US", "GB", "DE"]. Leave empty to use the single `marketplace` value. Codes are the same as the marketplace dropdown. |
departments | array | optional | Amazon department aliases to scope suggestions, e.g. ["aps", "kitchen"]. Leave empty for the all-departments default (`aps`). Common aliases: aps, electronics, computers, fashion, kitchen, stripbooks, beauty, hpc, pet-supplies, toys-and-games, home-improvement, automotive, grocery, office-products, watches, shoes, luggage, digital-text, audible, amazon-devices, instant-video, todays-deals. |
expandAlphabet | boolean | optional | Append each letter a-z to every query (e.g. `yoga mat a`) to surface more than the per-query cap. |
expandPrefixAlphabet | boolean | optional | Prepend each letter a-z to every query (e.g. `a yoga mat`). Returns a different suggestion set from suffix expansion. |
expandNumbers | boolean | optional | Append each digit 0-9 to every query, useful for sizes, models and quantities. |
expandQuestions | boolean | optional | Query locale-aware question stems such as `how to`, `what is` and `where to buy` in front of each seed. |
expandComparisons | boolean | optional | Query comparison tokens such as `vs`, `or`, `versus` and `and` after each seed. |
expandPrepositions | boolean | optional | Query preposition tokens such as `for`, `with`, `without`, `under` and `over` after each seed. |
expandBuyerModifiers | boolean | optional | Query locale-aware buyer-intent modifiers such as `best`, `cheap`, `for men`, `for women` and `waterproof`. |
customSuffixes | array | optional | Additional suffixes to append to every query, e.g. ["for men", "waterproof", "iphone 15"]. |
maxDepth | integer | optional | Recursively re-query newly discovered suggestions as fresh seeds, up to this depth (0 = original seeds only; 3 = three hops). |
queryMode | string | optional | `enhanced` returns thumbnails, widgets and predictive text when Amazon provides them; `organic` is the plain keyword response; `both` requests both and unions the results. |
includeWidgets | boolean | optional | Emit Amazon's optional widget suggestions (carousels, refinements, entity cards) when the enhanced endpoint returns them. |
includeSeed | boolean | optional | Emit one `SEED` record per seed keyword in addition to Amazon's suggestions. |
dedupe | boolean | optional | Merge repeated suggestions into one record per seed, marketplace and department, with a relative volume proxy and provenance. Turn off to emit every occurrence. |
resultOrder | string | optional | Order within each seed, marketplace and department group. `volume` sorts by the relative query-count score (requires dedupe). |
mustContainSeed | boolean | optional | Drop suggestions that do not contain the original seed keyword. |
includeTerms | array | optional | Keep only suggestions containing at least one of these terms. Leave empty to keep all. |
excludeTerms | array | optional | Drop suggestions containing any of these terms. |
onlyQuestions | boolean | optional | Keep only question-shaped suggestions (question word or trailing question mark). |
onlyLongTail | boolean | optional | Keep only suggestions with three or more words. |
minWordCount | integer | optional | Drop suggestions with fewer words than this value. |
maxSuggestions | integer | optional | Hard cap on total records emitted in this run. |
maxSuggestionsPerKeyword | integer | optional | Cap emitted records per seed, marketplace and department. 0 means no per-seed cap. |
maxQueries | integer | optional | Hard cap on HTTP requests across the whole run. The run status message says when this cap stopped it. |
maxConcurrency | integer | optional | Parallel requests. Values above 8 give little extra speed and are more likely to be rate-limited. |
requestDelayMs | integer | optional | Pause per worker between requests. 0 is fastest; 100-250 is gentler. |
3. Start an Actor run
Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.
Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.
import json
import os
import urllib.request
# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
actor_input = json.load(stream)
token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
"https://api.apify.com/v2/acts/zgFNSzKiYNCzNrdL9/runs?timeout=120&maxTotalChargeUsd=0.50",
data=json.dumps(actor_input).encode("utf-8"),
headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.
4. Inspect the actual results
Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.
Amazon search-autocomplete keyword suggestions with marketplace, department, expansion lineage, relative volume proxy, search URLs, optional thumbnails and widget metadata.
Questions before you run
Which inputs are required?
The published required fields are keywords
What does this guide verify?
The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.
What if the run request times out?
Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.
Generated from source build Lh0Nho79lKMarONeP and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.