predictiveSearch
- Query
- Storefront
Returns type-ahead suggestions for a partly typed query: matching products, collections and suggested search terms. limit and limitScope cap the results overall or per type.
Arguments
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
limit | Int | Optional | ||
limitScope | PredictiveSearchLimitScope | Optional | ||
query | String! | Required | ||
searchableFields | [SearchableField!] | Optional | Deprecated | |
types | [PredictiveSearchType!] | Optional | ||
unavailableProducts | SearchUnavailableProductsType | Optional |
Returns
PredictiveSearchResult Type-ahead results for a partly typed search: matching products, collections, pages and articles, and suggested search terms.
| Field | Type | Description |
|---|---|---|
articles | [Article!]! | |
collections | [Collection!]! | |
pages | [Page!]! | |
products | [Product!]! | |
queries | [SearchQuerySuggestion!]! |
Example request
A starting point: required arguments as variables and a few fields of the result. Replace the placeholders.
Set STORE_ID and TANQORY_STOREFRONT_TOKEN in your environment first (Make your first API call).
curl
curl -X POST "https://$STORE_HOST/api/v1/stores/$STORE_ID/2026-10/graphql" \
-H "X-Tanqory-Storefront-Access-Token: $TANQORY_STOREFRONT_TOKEN" \
-H "Content-Type: application/json" \
--data '{"query":"query PredictiveSearch($query: String!) {\n predictiveSearch(query: $query) {\n articles { id }\n collections { id }\n pages { id }\n products { id }\n }\n}","variables":{"query":""}}'Node.js
// Node.js 18 or later (fetch is built in). Save as request.mjs and run: node request.mjs
const query = `query PredictiveSearch(\$query: String!) {
predictiveSearch(query: \$query) {
articles { id }
collections { id }
pages { id }
products { id }
}
}`;
const variables = {
"query": ""
};
const res = await fetch(`https://${process.env.STORE_HOST}/api/v1/stores/${process.env.STORE_ID}/2026-10/graphql`, {
method: 'POST',
headers: {
'X-Tanqory-Storefront-Access-Token': process.env.TANQORY_STOREFRONT_TOKEN,
'Content-Type': 'application/json',
},
body: JSON.stringify({ query, variables }),
});
console.log(res.status, JSON.stringify(await res.json(), null, 2));Python
# Python 3, standard library only. Save as request.py and run: python3 request.py
import json, os, urllib.request
query = """query PredictiveSearch($query: String!) {
predictiveSearch(query: $query) {
articles { id }
collections { id }
pages { id }
products { id }
}
}"""
variables = json.loads("""{
"query": ""
}""")
req = urllib.request.Request(
"https://" + os.environ["STORE_HOST"] + "/api/v1/stores/" + os.environ["STORE_ID"] + "/2026-10/graphql",
data=json.dumps({"query": query, "variables": variables}).encode(),
headers={
"X-Tanqory-Storefront-Access-Token": os.environ["TANQORY_STOREFRONT_TOKEN"],
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(req) as res:
print(res.status, json.dumps(json.load(res), indent=2))