The Autocomplete search type is optimized to search as a user types. Users can enter addresses quickly and easily, using a real-time suggestions list and fuzzy matching, along with Location-biasing in certain countries, while delimiters such as commas and dashes are handled accurately and transparently.
As your end user starts typing an address into a single text box, our API will attempt to autocomplete by providing a list of addresses that match the current input. Each keystroke will update the list with more accurate suggestions.
Methods
This is a two-step process involving two endpoint methods:
Search for an address. Autocomplete is optimised to provide suggestions as you type, but also works with addresses entered in full.
POST /address/search/v1: Setting any additional options is not required - Autocomplete is the default search type.
Retrieve the formatted address and optional enrichment data using the below:
Format the selected address, using the global_address_key. You can choose between:
GET /address/format/v1/{global_address_key}: Formats an address into the standard 7 line global layout, thereby creating a well formatted address for every country and territory.
POST /address/format/v1/{global_address_key}: Formats an address into one of your available custom layouts.
Simultanously retrieve Enrichment data for the selected address in the same format request by setting the Add-Enrichment header to true and specifying the Enrichment attributes you are interested in.
Recommended implementation
There are several ways this can be implemented into your solution. Here we will describe the way we recommend.
The user starts to type into the single text box. Suggestions will be displayed in a drop-down.
The end user can then either:
Continue to type for a more accurate selection in the drop-down.
Select from the results in the drop-down.
When a selection is made, the final address is displayed and any optional enrichment information shown per your website design i.e. a single text box or a multi-fielded layout.
The recommended workflow (as demonstrated by our sample code) is:
The relevant address and enrichment components can be stored in your database if required.