Malachyte Portal/Search

Autocomplete

Suggest search terms as shoppers type

What It Does

Autocomplete suggests search terms as the shopper types, based on the store's product titles.

Turning it on

Autocomplete is off by default. Ask the Malachyte contact to turn it on for the store.

Endpoint

POST /v1/search/autocomplete

Autocomplete uses the same x-api-key header and base URL as the Search API.

Request Body Fields

FieldTypeRequiredDescription
querystringYesWhat the shopper has typed so far.
visitor_idstringYesThe shopper's visitor ID, the same as in the Search API.
user_idstringOptionalThe logged-in shopper's ID, the same as in the Search API.
catalogintegerOptionalOnly needed if the store has more than one catalog.

Example Request

curl --location 'https://api-yoursite.malachyte.com/v1/search/autocomplete' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "query": "sh",
  "visitor_id": "3e92322a-d473-4c81-ab80-82dba7c31e65"
}'

Response

Up to 5 suggestions:

[
  { "key": "shoes", "count": 42, "popularity": 120 },
  { "key": "shirt", "count": 18, "popularity": 64 }
]
FieldDescription
keyThe suggested search term.
countHow many products contain the term.
popularityHow often the term has been used.

Errors

Status CodeDescription
503 Service UnavailableSuggestions couldn't be generated. Treat it as "no suggestions" and let the shopper keep typing.