- HTTP request
- Request body
- Response body
- LocationBias
- LocationRestriction
- Suggestion
- PlacePrediction
- FormattableText
- StringRange
- StructuredFormat
- QueryPrediction
Returns predictions for the given input.
HTTP request
POST https://places.googleapis.com/v1/places:autocomplete
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "input": string, "locationBias": { object ( |
Fields | |
---|---|
input |
Required. The text string on which to search. |
location |
Optional. Bias results to a specified location. At most one of |
location |
Optional. Restrict results to a specified location. At most one of |
included |
Optional. Included primary Place type (for example, "restaurant" or "gas_station") in Place Types (https://developers.google.com/maps/documentation/places/web-service/place-types), or only |
included |
Optional. Only include results in the specified regions, specified as up to 15 CLDR two-character region codes. An empty set will not restrict the results. If both |
language |
Optional. The language in which to return results. Defaults to en-US. The results may be in mixed languages if the language used in |
region |
Optional. The region code, specified as a CLDR two-character region code. This affects address formatting, result ranking, and may influence what results are returned. This does not restrict results to the specified region. To restrict results to a region, use |
origin |
Optional. The origin point from which to calculate geodesic distance to the destination (returned as |
input |
Optional. A zero-based Unicode character offset of If empty, defaults to the length of |
include |
Optional. If true, the response will include both Place and query predictions. Otherwise the response will only return Place predictions. |
session |
Optional. A string which identifies an Autocomplete session for billing purposes. Must be a URL and filename safe base64 string with at most 36 ASCII characters in length. Otherwise an INVALID_ARGUMENT error is returned. The session begins when the user starts typing a query, and concludes when they select a place and a call to Place Details or Address Validation is made. Each session can have multiple queries, followed by one Place Details or Address Validation request. The credentials used for each request within a session must belong to the same Google Cloud Console project. Once a session has concluded, the token is no longer valid; your app must generate a fresh token for each session. If the We recommend the following guidelines:
|
include |
Optional. Include pure service area businesses if the field is set to true. Pure service area business is a business that visits or delivers to customers directly but does not serve customers at their business address. For example, businesses like cleaning services or plumbers. Those businesses do not have a physical address or location on Google Maps. Places will not return fields including |
Response body
Response proto for places.autocomplete.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"suggestions": [
{
object ( |
Fields | |
---|---|
suggestions[] |
Contains a list of suggestions, ordered in descending order of relevance. |
LocationBias
The region to search. The results may be biased around the specified region.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field
|
|
rectangle |
A viewport defined by a northeast and a southwest corner. |
circle |
A circle defined by a center point and radius. |
LocationRestriction
The region to search. The results will be restricted to the specified region.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field
|
|
rectangle |
A viewport defined by a northeast and a southwest corner. |
circle |
A circle defined by a center point and radius. |
Suggestion
An Autocomplete suggestion result.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field
|
|
place |
A prediction for a Place. |
query |
A prediction for a query. |
PlacePrediction
Prediction results for a Place Autocomplete prediction.
JSON representation |
---|
{ "place": string, "placeId": string, "text": { object ( |
Fields | |
---|---|
place |
The resource name of the suggested Place. This name can be used in other APIs that accept Place names. |
place |
The unique identifier of the suggested Place. This identifier can be used in other APIs that accept Place IDs. |
text |
Contains the human-readable name for the returned result. For establishment results, this is usually the business name and address.
This text may be different from the May be in mixed languages if the request |
structured |
A breakdown of the Place prediction into main text containing the name of the Place and secondary text containing additional disambiguating features (such as a city or region).
|
types[] |
List of types that apply to this Place from Table A or Table B in https://developers.google.com/maps/documentation/places/web-service/place-types. A type is a categorization of a Place. Places with shared types will share similar characteristics. |
distance |
The length of the geodesic in meters from |
FormattableText
Text representing a Place or query prediction. The text may be used as is or formatted.
JSON representation |
---|
{
"text": string,
"matches": [
{
object ( |
Fields | |
---|---|
text |
Text that may be used as is or formatted with |
matches[] |
A list of string ranges identifying where the input request matched in These values are Unicode character offsets of |
StringRange
Identifies a substring within a given text.
JSON representation |
---|
{ "startOffset": integer, "endOffset": integer } |
Fields | |
---|---|
start |
Zero-based offset of the first Unicode character of the string (inclusive). |
end |
Zero-based offset of the last Unicode character (exclusive). |
StructuredFormat
Contains a breakdown of a Place or query prediction into main text and secondary text.
For Place predictions, the main text contains the specific name of the Place. For query predictions, the main text contains the query.
The secondary text contains additional disambiguating features (such as a city or region) to further identify the Place or refine the query.
JSON representation |
---|
{ "mainText": { object ( |
Fields | |
---|---|
main |
Represents the name of the Place or query. |
secondary |
Represents additional disambiguating features (such as a city or region) to further identify the Place or refine the query. |
QueryPrediction
Prediction results for a Query Autocomplete prediction.
JSON representation |
---|
{ "text": { object ( |
Fields | |
---|---|
text |
The predicted text. This text does not represent a Place, but rather a text query that could be used in a search endpoint (for example, Text Search).
May be in mixed languages if the request |
structured |
A breakdown of the query prediction into main text containing the query and secondary text containing additional disambiguating features (such as a city or region).
|