loading

Step 2: Autocomplete

Universal Autocomplete

Universal Autocomplete will return a list of suggested queries across all verticals based on the input typed in by a user.

Let’s send a GET request to https://liveapi.yext.com/v2/accounts/me/answers/autocomplete with the following parameters:

Parameter Value
api_key 4be28826989e90232722e9bf2769fbf2
experienceKey cpg-beverages
locale en
v 20210303
input how

In this example, the user has typed “how” into the search bar: https://liveapi.yext.com/v2/accounts/me/answers/autocomplete?v=20210311&api_key=4be28826989e90232722e9bf2769fbf2&experienceKey=cpg-beverages&locale=en&input=how

The autocomplete endpoint returns a structured set of autocomplete options (results) each with the following format:

{
    "value": "how to make vodka martini",
    "matchedSubstrings": [
        {
            "offset": 0,
            "length": 3
        }
    ],
    "queryIntents": []
},

The value is the string to display to the user while the matched substrings can we used for highlighting. Query Intents will indicate whether or not the string has near me intent. One common pattern is to ask for HTML5 geolocation if a user runs a search with near me intent.

For full reference to the Universal Autocomplete API see here.

Vertical Autocomplete

Vertical Autocomplete is very similar to Universal Autocomplete but will only return a list of suggested queries within a specified vertical based on the specified vertical key.

Sending a GET request to https://liveapi.yext.com/v2/accounts/me/answers/vertical/autocomplete with the following parameters:

Parameter Value
api_key 4be28826989e90232722e9bf2769fbf2
experienceKey cpg-beverages
locale en
v 20210303
verticalKey drinks
input how

This will only populate the autocomplete for suggestions in the drinks vertical. The results will follow the same format as Universal Autocomplete. Check out the full response here: https://liveapi.yext.com/v2/accounts/me/answers/vertical/autocomplete?v=20210311&api_key=4be28826989e90232722e9bf2769fbf2&experienceKey=cpg-beverages&locale=en&input=how&verticalKey=drinks

For full reference to the Vertical Autocomplete API see here.