Skip to content

Suggest products as the shopper types

GET
/public/stores/{storeRef}/search/catalog/autocomplete
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.

storeRef
required
string

The store’s ref, as returned by GET /stores.

q
required
string

Example

T-sh

The search query string for autocomplete

collection
required
string

Example

products

The collection to search within for autocomplete

limit
number
>= 1

Example

5

The limit of autocomplete results

Media typeapplication/json
object
found

Number of suggestions found. Absent when the query is shorter than two characters.

number
data

The suggestions, best first. Absent when the query is shorter than two characters.

Array<object>
object
document
required

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
key
additional properties
any
highlight

Highlighted fragments of the matched fields, keyed by field name. Absent on results read from the database.

object
key
additional properties
any
highlights

The same fragments as a list, one entry per matched field. Absent on results read from the database.

Array<object>
object
key
additional properties
any
suggestions

Always empty. Present only when the query is shorter than two characters.

Array
facet_counts

Facet counts; always empty for suggestions.

Array<object>
object
key
additional properties
any
page

The page, always 1.

number
request_params

The request parameters as the search ran them.

object
per_page
required

Number of matches per page.

number
q
required

The search query.

string

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.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

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.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}