This document walks you through making a basic request to the Places Aggregate API and understanding the response, which includes a count of matching places.
To use Places Aggregate API, send an HTTP POST request to the computeInsights
endpoint as follows:
https://areainsights.googleapis.com/v1:computeInsights
Refine your request by providing region and type parameters in the JSON body. This example shows a request to return the count of restaurants in San Francisco that are operational, moderately priced, and rated between 4 and 5 stars.
curl --location 'https://areainsights.googleapis.com/v1:computeInsights' \
--header 'X-Goog-Api-Key: API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"insights":[
"INSIGHT_COUNT"
],
"filter":{
"locationFilter":{
"region":{
"place":"places/ChIJIQBpAG2ahYAR_6128GcTUEo"
}
},
"typeFilter":{
"includedTypes":[
"restaurant"
]
},
"operatingStatus":[
"OPERATING_STATUS_OPERATIONAL"
],
"priceLevels":[
"PRICE_LEVEL_INEXPENSIVE"
],
"ratingFilter":{
"minRating":4.0,
"maxRating":5.0
}
}
}'
Places Aggregate API response
The following response from the example request above shows the count of restaurants that match the criteria.
{ "count": "850" }
Try it!
The API Explorer lets you make sample requests so that you can get familiar with the API and the API options.
- Select the API icon,
,
on the right side of the page. - Optionally expand Show standard parameters to set any parameters.
- Optionally edit the Request body.
- Select Execute button. In the dialog, choose the account that you want to use to make the request.
In the API Explorer panel, select the expand icon,
, to expand the API Explorer window.
What's next
- Explore more examples of what you can achieve with Places Aggregate API.
- Look at the request parameters in more detail.
- View the full API documentation.