v1
latestOpenAPI 3.0.22026-08-0426137631.3 KBAutocomplete API
The Autocompletion API provides real-time, personalized, typo resistant typeahead for your search bar. You send this API what users are currently typing, and the API returns the complete search query suggestions.
Personalized typeahead
Personalized typeahead is an extreme example of personalized search. The personalization starts immediately when users enter even just one character. The typeahead results are personalized so that the entries most likely to drive conversion for the current user are ranked at the top. Miso will predict what the user is looking for in real-time based on their interests and past behaviors.
Basic usage
The request schema of Autocompletion API is similar to that of Search API: you put the search query users typed so far, and the user_id or anonymous_id for Miso to identify the current user. For example, when a user types the first character r, you send Miso the following request:
POST /v1/search/autocomplete
{
"q":"r",
"user_id":"user-123"
}
The response will be like:
{
"message": "success",
"data": {
"took": 50,
"miso_id": "e93a6d02-0a7a-11eb-a896-d28586dc1386",
"completions": {
"title": [
{
"text": "Robin Hood: Prince of Thieves (1991)",
"text_with_markups": "R<mark>obin Hood: Prince of Thieves (1991)</mark>",
"product": {
"product_id": "tmdb-8367"
}
},
{
"text": "Reservoir Dogs (1992)",
"text_with_markups": "R<mark>eservoir Dogs (1992)</mark>",
"product": {
"product_id": "tmdb-500"
}
},
...
]
}
}
}
- took: the amount of time (in milliseconds) Miso took to answer the query
- completions: an dictionary of autocompletion candidates from different sources. By default, we only run autocompletion against the titles of products, but you can choose to get autocompletion candidates from other fields using the completion_fields parameters.
- completions.title[].text: the text of completion candidates
- completions.title[].text_with_markups: the completion candidates with the part of text that users haven't typed yet surrounded by <mark> HTML tags.
- completions.title[].product: the product record whose title matches the autocompletion candidate. This object can be used to implement direct-to-product links: when they click on the link they will go directly to the product page instead of the search result page. By default, only the product_id field is returned, you use fl request parameter to get more fields returned in the product object.
Typo resistance
Miso's autocompletion algorithm accepts up to 4 typos in the query string. For example, users may try to find the movie Robin Hood, but make two typos in the query, which becomes robonhood instead (robin->robon, and a space is missing).
POST /v1/search/autocomplete
{
"q":"robanhood",
"user_id":"user-123"
}
Miso can still find the movie "Robin Hood: Prince of Thieves" as a autocompletion candidate.
{
"message": "success",
"data": {
"took": 50,
"miso_id": "e93a6d02-0a7a-11eb-a896-d28586dc1386",
"completions": {
"title": [
{
"text": "Robin Hood: Prince of Thieves (1991)",
"text_with_markups": "Rob<mark>in Hood: Prince of Thieves (1991)</mark>",
"product": {
"product_id": "tmdb-8367"
}
},
...
]
}
}
}
Completion fields
The auto-completions are made against your product attributes. By default, Miso finds completion candidates from the title field. The completion_fields parameter lets you specify the attributes you want to perform auto-completion for. For example, the following query will return auto-completion candidates from the title and a custom attribute field:custom_attributes.director.
POST /v1/search/autocomplete
{
"q": "rob",
"user_id": "user-123",
"completion_fields": [
"title",
"custom_attributes.director"
]
}
The response will be like the following:
{
"message": "success",
"data": {
"took": 52,
"miso_id": "16d95080-0bb0-11eb-948d-66359cf29022",
"completions": {
"title": [
{
"text": "Robin Hood: Prince of Thieves (1991)",
"text_with_markups": "Rob<mark>in Hood: Prince of Thieves (1991)</mark>",
"product": {
"product_id": "tmdb-8367"
}
},
{
"text": "RoboCop (1987)",
"text_with_markups": "Rob<mark>oCop (1987)</mark>",
"product": {
"product_id": "tmdb-5548"
}
},
...
],
"custom_attributes.director": [
{
"text": "Robert Z. Leonard",
"text_with_markups": "<mark>Rob</mark>ert Z. Leonard",
},
...
]
}
}
}
Request body
Example request
{
"additional_interactions": [
{
"duration": 61.5,
"product_ids": [
"123ABC-BLACK"
],
"product_group_ids": [
"123ABC"
],
"user_id": "user_1234",
"anonymous_id": "86D51273AD8BF84217E1567B6CBE7152D7034404",
"miso_id": "123e4567-e89b-12d3-a456-426614174000",
"context": {
"campaign": {
"name": "spring_sale",
"source": "Google",
"medium": "cpc",
"term": "running+shoes",
"content": "textlink"
},
"truncated_ip": "1.1.1.0",
"locale": "en-US",
"region": "US East",
"page": {
"url": "https://example.com/miso-tshirt-123ABC",
"referrer": "https://example.com/",
"title": "My Product Page"
},
"user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
"custom_context": {
"session_variable_1": [
"value_1",
"value_2"
]
}
}
}
]
}Response
Successful Response
Example response
{
"data": {
"miso_id": "123e4567-e89b-12d3-a456-426614174000",
"completions": {
"title": [
{
"text": "Miso Japanese Shiba Inu Dog Eating Miso Soup T-Shirt",
"type": "title",
"product": {
"product_id": "123ABC-S-Black"
}
}
],
"brand": [
{
"text": "Miso",
"type": "brand"
},
{
"text": "Mitsui",
"type": "brand"
}
]
}
}
}