Google Search autocomplete API?

Viewed 72038

Does Google provide API access to autocomplete for search like on the actual site? I have not been able to find anything.

I would like to use Google's autocomplete logic for web search on my own site which relies on Google's search API.

6 Answers

You should use AutocompleteService and pass that text box value into the service.getPlacePredictions function. It send the data in callback function.

let service = new google.maps.places.AutocompleteService();

let displaySuggestions = function(predictions, status) {
}

service.getPlacePredictions({
    input: value
}, displaySuggestions);

Base: https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompleteService.getPlacePredictions

example: https://dzone.com/articles/implement-and-optimize-autocomplete-with-google-pl

Related