Suggest products as the shopper types
const url = 'https://apibase.ecomweb.app/api/v1/public/stores/example/search/catalog/autocomplete?q=T-sh&collection=products&limit=5';const options = {method: 'GET', headers: {'x-storefront-api-key': '<x-storefront-api-key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://apibase.ecomweb.app/api/v1/public/stores/example/search/catalog/autocomplete?q=T-sh&collection=products&limit=5' \ --header 'x-storefront-api-key: <x-storefront-api-key>'Returns product matches for a partial query, for a search box. collection must be products. Only active products published to the online store are suggested. A query shorter than two characters answers with an empty suggestions list. limit is the number of suggestions, 3 by default.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Query Parameters
Section titled “Query Parameters”Example
T-shThe search query string for autocomplete
Example
productsThe collection to search within for autocomplete
Example
5The limit of autocomplete results
Responses
Section titled “Responses”object
Number of suggestions found. Absent when the query is shorter than two characters.
The suggestions, best first. Absent when the query is shorter than two characters.
object
The indexed record. For products it holds fields such as id, name, slug, description, main_image_url, min_price, max_price, has_promotion, variant_mode and rating_average; for blog posts, id, title, slug, excerpt and published_at.
object
Highlighted fragments of the matched fields, keyed by field name. Absent on results read from the database.
object
The same fragments as a list, one entry per matched field. Absent on results read from the database.
object
Always empty. Present only when the query is shorter than two characters.
Facet counts; always empty for suggestions.
object
The page, always 1.
The request parameters as the search ran them.
object
Number of matches per page.
The search query.
Example generated
{ "found": 1, "data": [ { "document": {}, "highlight": {}, "highlights": [ {} ] } ], "suggestions": [ "example" ], "facet_counts": [ {} ], "page": 1, "request_params": { "per_page": 1, "q": "example" }}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}