Autocomplete: Get Suggestions
Autocomplete
Autocomplete: Get Suggestions
Autocomplete API endpoint returning ranked search-query suggestions as shoppers type into your storefront search bar.
GET
Autocomplete: Get Suggestions
The Autocomplete endpoint returns ranked query-text suggestions for a partial search term. It does not return products, product previews, or images — use the Search endpoint to fetch products for a chosen suggestion.
When no
query is provided, the endpoint returns the store’s top trending queries (subject to the same brand curation rules as live suggestions).
Authorization
Token-based authentication header in the form of
<YOUR_LAYERS_TOKEN>.Headers
Query parameters
The partial query you want suggestions for. Maximum 255 characters. Sanitized server-side; queries shorter than 2 characters after sanitization are treated as empty and return trending suggestions instead.
Response
Ranked array of suggestion strings. Prefix matches appear first, followed by non-prefix matches that clear the relevance threshold. Each string is the suggestion text the shopper should see — either the cluster’s canonical query or its curated display label when one is configured.
The
query value exactly as sent by the client. null when the request omits query or when the sanitized query is too short.The lowercased, trimmed form of
originalQuery used internally for matching. null when no query was effectively provided.Optional metadata. Present only when a semantic redirect matches the current query.
Semantic Redirects: When the autocomplete query semantically matches a configured semantic redirect term, the response includes a
_meta.redirect object with the redirect URL. This lets you redirect users directly from the typeahead experience before they submit a full search.Suggestion quality
Layers applies several techniques to keep autocomplete suggestions relevant and concise.Brand curation
You can layer a natural-language brand prompt on top of the default suggestion pipeline. Layers uses the prompt — together with your store description — to suppress off-brand suggestions and rewrite display labels for customers. Suppressed clusters never appear inmatchedQueries, and curated clusters return their rewritten text in place of the canonical query. Matching against raw customer queries is unchanged. See Autocomplete curation for configuration details.