Make your first request

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.

Try it!

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": "850"
}

Try it!

The API Explorer lets you make sample requests so that you can get familiar with the API and the API options.

  1. Select the API icon, Expand the API Explorer., on the right side of the page.
  2. Optionally expand Show standard parameters and set to set any parameters.
  3. Optionally edit the Request body.
  4. Select Execute button. In the dialog, choose the account that you want to use to make the request.
  5. In the API Explorer panel, select the expand icon, Expand the API Explorer., to expand the API Explorer window.

What's next