Places API supports the existing Text Search. If you are familiar with the existing Text Search, the new version of Text Search makes the following changes:
- The new Text Search uses HTTP POST requests. Pass parameters in the request body or in headers as part of an HTTP POST request. In contrast, with the existing Text Search, you pass URL parameters using an HTTP GET request.
- Field masking is required. You must specify which fields you want returned in the response. There is no default list of returned fields. If you omit this list, the methods return an error. For more information, see FieldMask.
- The new Text Search supports both API keys and OAuth tokens as the authentication mechanism.
- Only JSON is supported as a response format in the new Text Search.
The existing Text Search lets you specify latitude and longitude coordinates in the query string. For example:
query=37.4239,-122.0925
. That option is not supported in the new Text Search.Use Reverse Geocoding to search on coordinates and return an address, or Nearby Search (New) to find places around a certain location.
- The JSON response format for the Text Search (New) API has changed from the format of the existing APIs. For more details, see Migrate the Places API response.
The following table lists parameters in the existing Text Search that have been renamed or modified for the new Text Search, or parameters that are no longer supported.
Current parameter | New parameter | Notes |
---|---|---|
evOptions |
New parameter. | |
language |
languageCode |
|
location |
locationBias |
|
maxprice/minprice |
priceLevels |
|
opennow |
openNow |
|
pagetoken |
pageToken |
|
query |
textQuery |
Required in all requests. |
radius |
locationBias |
Specify the radius when defining a locationBias . |
region |
regionCode |
|
type |
includedType |
Only takes a single value. |
strictTypeFiltering |
New parameter. |
Example request
The following example GET request uses the existing Text Search. In this example, you request a JSON response containing information about "Spicy Vegetarian Food in Sydney, Australia" and pass all parameters as URL parameters:
curl -L -X GET \ 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=Spicy%20Vegetarian%20Food%20in%20Sydney%20Australia&key=API_KEY
With Text Search (New), you make a POST request and pass all parameters in the JSON request body or in headers as part of the POST request. This example also uses a field mask so the response only includes the display name and formatted address of the place:
curl -X POST -d '{ "textQuery" : "Spicy Vegetarian Food in Sydney, Australia" }' \ -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \ -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress' \ 'https://places.googleapis.com/v1/places:searchText'