Get a predicted list of addresses using the Autocomplete API
The /autocomplete
endpoint provides a list of five closely matching addresses provided in the Google address database for a given input string. You can use this API to match on full words and substrings for a place’s names or addresses.
Mandatory parameters
-
input
: Theinput
refers to a string or letters of an address that is to be autocompleted. -
sessionId
: ThesessionId
is the user generated UUID of a session (also called session token). It consists of multiple autocomplete requests and ends with a place fetch request. In other words, the session tokens bundle queries made to the Autocomplete APIs and Place APIs into a single session.Note
A session begins when you begin typing a query to the Autocomplete API and ends when you select an address from the list of suggestions, which sends a fetch to the Place API. After selecting a place based on the autocompleted suggestions, the token is no longer valid. Sessions also end after a short period of time if no location is selected.
Optional parameters
-
location
: Thelocation
refers to any place on earth that is in the form of latitude and longitude coordinates. -
country
: Thecountry
refers to the two character, ISO 3166-1 Alpha-2 compatible country code. This parameter helps in identifying the place by country. Find the codes of different countries in thislist
.
For example, let’s say you want to get the autocompleted list of places for the partial string “Central Pa”.
In this case, you can send a POST
request by calling the /autocomplete
endpoint with the following payload:
{
"input": "Central Pa",
"sessionId": "f6567dd8-e069-418e-8893-7d22fcf12459"
}
This request returns the following autocompleted places:
{
"result": {
"predictions": [
{
"description": "Central Park South, New York, NY, USA",
"placeId": "EiVDZW50cmFsIFBhcmsgU291dGgsIE5ldyBZb3JrLCBOWSwgVVNBIi4qLAoUChIJu3GRLvdYwokRYtzyuYIf3zoSFAoSCTsIP9OlT8KJEWL-d-EGjwvI"
},
{
"description": "Central Park West, New York, NY, USA",
"placeId": "EiRDZW50cmFsIFBhcmsgV2VzdCwgTmV3IFlvcmssIE5ZLCBVU0EiLiosChQKEgkVVHPBmljCiRFwbhPvmnVSRhIUChIJOwg_06VPwokRYv534QaPC8g"
},
{
"description": "Central Park North, New York, NY, USA",
"placeId": "EiVDZW50cmFsIFBhcmsgTm9ydGgsIE5ldyBZb3JrLCBOWSwgVVNBIi4qLAoUChIJ6XWMiRn2wokROZOJYqrTD4kSFAoSCTsIP9OlT8KJEWL-d-EGjwvI"
},
{
"description": "Central Park Blvd, Denver, CO, USA",
"placeId": "EiJDZW50cmFsIFBhcmsgQmx2ZCwgRGVudmVyLCBDTywgVVNBIi4qLAoUChIJW79GQXl7bIcRoIQol_5XC38SFAoSCc8XHyOqgGuHEdY2iif49I4R"
},
{
"description": "Central Park Avenue, Yonkers, NY, USA",
"placeId": "EiVDZW50cmFsIFBhcmsgQXZlbnVlLCBZb25rZXJzLCBOWSwgVVNBIi4qLAoUChIJrb0BuyeTwokRCRUteZIwiGQSFAoSCaGvQwkIwMKJEaLa2KSEc5a-"
}
],
"status": "OK",
"errorMessage": null
}
}
From the result, you can see the five closely matching autocompleted addresses to the input string “Central Pa”.
For the schema information of this endpoint, please refer to /autocomplete
.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.