Predictive Search API reference

You can access predictive search results on a theme by making requests through the Predictive Search API.

For more information on how to use predictive search on a theme, refer to Add predictive search to your theme.

GET /search/suggest.json

Get predictive results for a specified search query. Predictive search supports suggestions for products, collections, pages, and articles.

Query parameters

Query parameter Type Description
q (required) String The search query.
resources (required) Hash Requests resources results for the given query, based on the type and limit fields.
type (required) Comma-separated values Specifies the type of results requested. Valid values: product, page, article, collection.
limit (optional) Integer Limits the number of results returned. Default: 10. Min: 1. Max: 10.
options (optional) Hash Specifies options for the requested resources based on the unavailable_products and fields settings.
unavailable_products (optional) String Specifies whether to display results for unavailable products. The three possible options are show, hide, and last. Set to last to display unavailable products below other matching results. Set to hide to filter out unavailable products from the search results. Default: last.
fields (optional) Comma-separated values Specifies the list of fields to search on. Valid fields are: author, body, product_type, tag, title, variants.barcode, variants.sku, variants.title, and vendor. The default fields searched on are: title, product_type, variants.title, and vendor. For the best search experience, we recommend searching on the default field set or as few fields as possible.

Example request_object

Example request using jQuery:

Example request using Fetch: