# Method: computeInsights

- [HTTP request](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.request_body)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.response_body)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.ComputeInsightsResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#body.aspect)
- [Insight](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Insight)
- [Filter](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Filter)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Filter.SCHEMA_REPRESENTATION)
- [LocationFilter](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LocationFilter)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LocationFilter.SCHEMA_REPRESENTATION)
- [Circle](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Circle)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Circle.SCHEMA_REPRESENTATION)
- [LatLng](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng.SCHEMA_REPRESENTATION)
- [Region](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Region)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Region.SCHEMA_REPRESENTATION)
- [CustomArea](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#CustomArea)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#CustomArea.SCHEMA_REPRESENTATION)
- [Polygon](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Polygon)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Polygon.SCHEMA_REPRESENTATION)
- [TypeFilter](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#TypeFilter)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#TypeFilter.SCHEMA_REPRESENTATION)
- [OperatingStatus](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#OperatingStatus)
- [PriceLevel](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PriceLevel)
- [RatingFilter](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#RatingFilter)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#RatingFilter.SCHEMA_REPRESENTATION)
- [PlaceInsight](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PlaceInsight)
  - [JSON representation](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PlaceInsight.SCHEMA_REPRESENTATION)
- [Try it!](https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#try-it)

This method lets you retrieve insights about areas using a variety of filter such as: area, place type, operating status, price level and ratings. Currently "count" and "places" insights are supported. With "count" insights you can answer questions such as "How many restaurant are located in California that are operational, are inexpensive and have an average rating of at least 4 stars" (see `insight` enum for more details). With "places" insights, you can determine which places match the requested filter. Clients can then use those place resource names to fetch more details about each individual place using the Places API.

### HTTP request

`POST https://areainsights.googleapis.com/v1:computeInsights`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "insights": [ enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Insight`) ], "filter": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Filter`) } } ``` |

| Fields ||
|---|---|
| `insights[]` | ``enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Insight`)`` Required. Insights to compute. Currently only INSIGHT_COUNT and INSIGHT_PLACES are supported. |
| `filter` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Filter`)`` Required. Insight filter. |

### Response body

Response for the v1.computeInsights RPC.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "placeInsights": [ { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PlaceInsight`) } ], "count": string } ``` |

| Fields ||
|---|---|
| `placeInsights[]` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PlaceInsight`)`` Result for Insights.INSIGHT_PLACES. |
| `count` | `string (https://developers.google.com/discovery/v1/type-format format)` Result for Insights.INSIGHT_COUNT. |

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

## Insight

Supported insights.

| Enums ||
|---|---|
| `INSIGHT_UNSPECIFIED` | Not Specified. |
| `INSIGHT_COUNT` | Count insight. When this insight is specified v1.computeInsights returns the number of places that match the specified filter criteria. Example request: { "insights": ["INSIGHT_COUNT"], "filter": { "locationFilter": { "region": { "place": "places/ChIJPV4oX_65j4ARVW8IJ6IJUYs" } }, "typeFilter": { "includedTypes": ["restaurant"] }, "operatingStatus": ["OPERATING_STATUS_OPERATIONAL"], "priceLevels": [ "PRICE_LEVEL_FREE", "PRICE_LEVEL_INEXPENSIVE" ], "ratingFilter": { "minRating": 4.0 } } } Example response: { "count": 1234 } |
| `INSIGHT_PLACES` | Return Places When this insight is specified v1.computeInsights returns places IDs that match the specified filter criteria. Example request: { "insights": ["INSIGHT_PLACES"], "filter": { "locationFilter": { "region": { "place": "places/ChIJPV4oX_65j4ARVW8IJ6IJUYs" } }, "typeFilter": { "includedTypes": ["restaurant"] }, "operatingStatus": ["OPERATING_STATUS_OPERATIONAL"], "priceLevels": [ "PRICE_LEVEL_FREE", "PRICE_LEVEL_INEXPENSIVE" ], "ratingFilter": { "minRating": 4.0 } } } Example response: { "placeInsights": [ {"place": "places/ABC"}, {"place": "places/PQR"}, {"place": "places/XYZ"} ] } |

## Filter

Filters for the v1.computeInsights RPC.

| JSON representation |
|---|
| ``` { "locationFilter": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LocationFilter`) }, "typeFilter": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#TypeFilter`) }, "operatingStatus": [ enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#OperatingStatus`) ], "priceLevels": [ enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PriceLevel`) ], "ratingFilter": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#RatingFilter`) } } ``` |

| Fields ||
|---|---|
| `locationFilter` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LocationFilter`)`` Required. Restricts results to places which are located in the area specified by location filters. |
| `typeFilter` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#TypeFilter`)`` Required. Place type filters. |
| `operatingStatus[]` | ``enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#OperatingStatus`)`` Optional. Restricts results to places whose operating status is included on this list. If operatingStatus is not set, OPERATING_STATUS_OPERATIONAL is used as default. |
| `priceLevels[]` | ``enum (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#PriceLevel`)`` Optional. Restricts results to places whose price level is included on this list. If `priceLevels` is not set, all price levels are included in the results. |
| `ratingFilter` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#RatingFilter`)`` Optional. Restricts results to places whose average user ratings are in the range specified by ratingFilter. If ratingFilter is not set, all ratings are included in the result. |

## LocationFilter

Location filters.

Specifies the area of interest for the insight.

| JSON representation |
|---|
| ``` { // Union field `area` can be only one of the following: "circle": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Circle`) }, "region": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Region`) }, "customArea": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#CustomArea`) } // End of list of possible types for union field `area`. } ``` |

| Fields ||
|---|---|
| Union field `area`. One of the following must be specified. `area` can be only one of the following: ||
| `circle` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Circle`)`` Area as a circle. |
| `region` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Region`)`` Area as region. |
| `customArea` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#CustomArea`)`` Custom area specified by a polygon. |

## Circle

A circle is defined by a center point and radius in meters.

| JSON representation |
|---|
| ``` { "radius": integer, // Union field `center` can be only one of the following: "latLng": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng`) }, "place": string // End of list of possible types for union field `center`. } ``` |

| Fields ||
|---|---|
| `radius` | `integer` Optional. The radius of the circle in meters |
| Union field `center`. The center of the circle. `center` can be only one of the following: ||
| `latLng` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng`)`` The latitude and longitude of the center of the circle. |
| `place` | `string` **Format:** Must be in the format `places/PLACE_ID`, where `PLACE_ID` is the unique identifier of a place. For example: `places/ChIJgUbEo8cfqokR5lP9_Wh_DaM`. |

## LatLng

An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the [WGS84 standard](https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version). Values must be within normalized ranges.

| JSON representation |
|---|
| ``` { "latitude": number, "longitude": number } ``` |

| Fields ||
|---|---|
| `latitude` | `number` The latitude in degrees. It must be in the range \[-90.0, +90.0\]. |
| `longitude` | `number` The longitude in degrees. It must be in the range \[-180.0, +180.0\]. |

## Region

A region is a geographic boundary such as: cities, postal codes, counties, states, etc.

| JSON representation |
|---|
| ``` { // Union field `region` can be only one of the following: "place": string // End of list of possible types for union field `region`. } ``` |

| Fields ||
|---|---|
| Union field `region`. Defines a geographic region. Only one type of region (e.g. place) can specified at a time. `region` can be only one of the following: ||
| `place` | `string` The unique identifier of a specific geographic region. |

## CustomArea

Custom Area.

| JSON representation |
|---|
| ``` { "polygon": { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Polygon`) } } ``` |

| Fields ||
|---|---|
| `polygon` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#Polygon`)`` Required. The custom area represented as a polygon |

## Polygon

A polygon is represented by a series of connected coordinates in an counterclockwise ordered sequence. The coordinates form a closed loop and define a filled region. The first and last coordinates are equivalent, and they must contain identical values. The format is a simplified version of GeoJSON polygons (we only support one counterclockwise exterior ring).

| JSON representation |
|---|
| ``` { "coordinates": [ { object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng`) } ] } ``` |

| Fields ||
|---|---|
| `coordinates[]` | ``object (`https://developers.google.com/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#LatLng`)`` Optional. The coordinates that define the polygon. |

## TypeFilter

Place type filters.

Only Place types from [Table a](https://developers.google.com/maps/documentation/places/web-service/place-types#table-a) are supported.

A place can only have a single primary type associated with it. For example, the primary type might be "mexican_restaurant" or "steak_house". Use includedPrimaryTypes and excludedPrimaryTypes to filter the results on a place's primary type.

A place can also have multiple type values associated with it. For example a restaurant might have the following types: "seafood_restaurant", "restaurant", "food", "point_of_interest", "establishment". Use includedTypes and excludedTypes to filter the results on the list of types associated with a place.

If a search is specified with multiple type restrictions, only places that satisfy all of the restrictions are returned. For example, if you specify {"includedTypes": \["restaurant"\], "excludedPrimaryTypes": \["steak_house"\]}, the returned places provide "restaurant" related services but do not operate primarily as a "steak_house".

If there are any conflicting types, i.e. a type appears in both includedTypes and excludedTypes types or includedPrimaryTypes and excludedPrimaryTypes, an INVALID_ARGUMENT error is returned.

One of includedTypes or includedPrimaryTypes must be set.

| JSON representation |
|---|
| ``` { "includedTypes": [ string ], "excludedTypes": [ string ], "includedPrimaryTypes": [ string ], "excludedPrimaryTypes": [ string ] } ``` |

| Fields ||
|---|---|
| `includedTypes[]` | `string` Optional. Included Place types. |
| `excludedTypes[]` | `string` Optional. Excluded Place types. |
| `includedPrimaryTypes[]` | `string` Optional. Included primary Place types. |
| `excludedPrimaryTypes[]` | `string` Optional. Excluded primary Place types. |

## OperatingStatus

Operating status of the place.

| Enums ||
|---|---|
| `OPERATING_STATUS_UNSPECIFIED` | Not specified. This value should not be used. |
| `OPERATING_STATUS_OPERATIONAL` | The place is operational and its open during its defined hours. |
| `OPERATING_STATUS_PERMANENTLY_CLOSED` | The Place is no longer in business. |
| `OPERATING_STATUS_TEMPORARILY_CLOSED` | The place is temporarily closed and expected to reopen in the future. |

## PriceLevel

Price level of the place.

| Enums ||
|---|---|
| `PRICE_LEVEL_UNSPECIFIED` | Not specified. This value should not be used. |
| `PRICE_LEVEL_FREE` | Place provides free services. |
| `PRICE_LEVEL_INEXPENSIVE` | Place provides inexpensive services. |
| `PRICE_LEVEL_MODERATE` | Place provides moderately priced services. |
| `PRICE_LEVEL_EXPENSIVE` | Place provides expensive services. |
| `PRICE_LEVEL_VERY_EXPENSIVE` | Place provides very expensive services. |

## RatingFilter

Average user rating filters.

| JSON representation |
|---|
| ``` { "minRating": number, "maxRating": number } ``` |

| Fields ||
|---|---|
| `minRating` | `number` Optional. Restricts results to places whose average user rating is greater than or equal to minRating. Values must be between 1.0 and 5.0. |
| `maxRating` | `number` Optional. Restricts results to places whose average user rating is strictly less than or equal to maxRating. Values must be between 1.0 and 5.0. |

## PlaceInsight

Holds information about a place

| JSON representation |
|---|
| ``` { "place": string } ``` |

| Fields ||
|---|---|
| `place` | `string` The unique identifier of the place. This resource name can be used to retrieve details about the place using the [Places API](https://developers.google.com/maps/documentation/places/web-service/reference/rest/v1/places/get). |