This document walks you through making a basic request to the Places Insights API and understanding the response, which includes a count of matching places.
To use Place Insights, 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 Insights API response
The following response from the example request above shows the count of restaurants that match the criteria.
{ "count": "846" }
What's next
- Explore more examples of what you can achieve with Places Insights.
- Look at the request parameters in more detail.
- View the full API documentation.