/
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
| Field | Type | Required | Description |
|---|---|---|---|
query | string | Yes | What the shopper has typed so far. |
visitor_id | string | Yes | The shopper's visitor ID, the same as in the Search API. |
user_id | string | Optional | The logged-in shopper's ID, the same as in the Search API. |
catalog | integer | Optional | Only 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 }
]| Field | Description |
|---|---|
key | The suggested search term. |
count | How many products contain the term. |
popularity | How often the term has been used. |
Errors
| Status Code | Description |
|---|---|
| 503 Service Unavailable | Suggestions couldn't be generated. Treat it as "no suggestions" and let the shopper keep typing. |