Documentation ¶
Overview ¶
Package areainsights provides access to the Places Insights API.
For product documentation, see: https://g3doc.corp.google.com/geo/platform/area_insights/README.md?cl=head
Library status ¶
These client libraries are officially supported by Google. However, this library is considered complete and is in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
When possible, we recommend using our newer [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) that are still actively being worked and iterated on.
Creating a client ¶
Usage example:
import "google.golang.org/api/areainsights/v1" ... ctx := context.Background() areainsightsService, err := areainsights.NewService(ctx)
In this example, Google Application Default Credentials are used for authentication. For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
Other authentication options ¶
To use an API key for authentication (note: some APIs do not support API keys), use google.golang.org/api/option.WithAPIKey:
areainsightsService, err := areainsights.NewService(ctx, option.WithAPIKey("AIza..."))
To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow, use google.golang.org/api/option.WithTokenSource:
config := &oauth2.Config{...} // ... token, err := config.Exchange(ctx, ...) areainsightsService, err := areainsights.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
See google.golang.org/api/option.ClientOption for details on options.
Index ¶
- Constants
- type Circle
- type ComputeInsightsRequest
- type ComputeInsightsResponse
- type CustomArea
- type Filter
- type LatLng
- type LocationFilter
- type PlaceInsight
- type Polygon
- type RatingFilter
- type Region
- type Service
- type TypeFilter
- type V1ComputeInsightsCall
- func (c *V1ComputeInsightsCall) Context(ctx context.Context) *V1ComputeInsightsCall
- func (c *V1ComputeInsightsCall) Do(opts ...googleapi.CallOption) (*ComputeInsightsResponse, error)
- func (c *V1ComputeInsightsCall) Fields(s ...googleapi.Field) *V1ComputeInsightsCall
- func (c *V1ComputeInsightsCall) Header() http.Header
- type V1Service
Constants ¶
const ( // See, edit, configure, and delete your Google Cloud data and see the email // address for your Google Account. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" )
OAuth2 scopes used by this API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Circle ¶
type Circle struct { // LatLng: The latitude and longitude of the center of the circle. LatLng *LatLng `json:"latLng,omitempty"` // Place: The Place resource name of the center of the circle. Only point // places are supported. Place string `json:"place,omitempty"` // Radius: Optional. The radius of the circle in meters Radius int64 `json:"radius,omitempty"` // ForceSendFields is a list of field names (e.g. "LatLng") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "LatLng") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
Circle: A circle is defined by a center point and radius in meters.
func (Circle) MarshalJSON ¶
type ComputeInsightsRequest ¶
type ComputeInsightsRequest struct { // Filter: Required. Insight filter. Filter *Filter `json:"filter,omitempty"` // Insights: Required. Insights to compute. Currently only INSIGHT_COUNT and // INSIGHT_PLACES are supported. // // Possible values: // "INSIGHT_UNSPECIFIED" - Not Specified. // "INSIGHT_COUNT" - Count insight. When this insight is specified // ComputeInsights returns the number of places that match the specified filter // criteria. “` For example if the request is: ComputeInsightsRequest { // insights: INSIGHT_COUNT filter { location_filter {region: } type_filter // {included_types: "restaurant"} operating_status: // OPERATING_STATUS_OPERATIONAL price_levels: PRICE_LEVEL_FREE price_levels: // PRICE_LEVEL_INEXPENSIVE min_rating: 4.0 } } The method will return the count // of restaurants in California that are operational, with price level free or // inexpensive and have an average rating of at least 4 starts. Example // response: ComputeInsightsResponse { count: } “` // "INSIGHT_PLACES" - Return Places When this insight is specified // ComputeInsights returns Places that match the specified filter criteria. “` // For example if the request is: ComputeInsightsRequest { insights: // INSIGHT_PLACES filter { location_filter {region: } type_filter // {included_types: "restaurant"} operating_status: // OPERATING_STATUS_OPERATIONAL price_levels: PRICE_LEVEL_FREE price_levels: // PRICE_LEVEL_INEXPENSIVE min_rating: 4.0 } } The method will return list of // places of restaurants in California that are operational, with price level // free or inexpensive and have an average rating of at least 4 stars. Example // response: ComputeInsightsResponse { place_insights { place: "places/ABC" } // place_insights { place: "places/PQR" } place_insights { place: "places/XYZ" // } } “` Insights []string `json:"insights,omitempty"` // ForceSendFields is a list of field names (e.g. "Filter") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Filter") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
ComputeInsightsRequest: Request for the ComputeInsights RPC.
func (ComputeInsightsRequest) MarshalJSON ¶
func (s ComputeInsightsRequest) MarshalJSON() ([]byte, error)
type ComputeInsightsResponse ¶
type ComputeInsightsResponse struct { // Count: Result for Insights.INSIGHT_COUNT. Count int64 `json:"count,omitempty,string"` // PlaceInsights: Result for Insights.INSIGHT_PLACES. PlaceInsights []*PlaceInsight `json:"placeInsights,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Count") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Count") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
ComputeInsightsResponse: Response for the ComputeInsights RPC.
func (ComputeInsightsResponse) MarshalJSON ¶
func (s ComputeInsightsResponse) MarshalJSON() ([]byte, error)
type CustomArea ¶
type CustomArea struct { // Polygon: Required. The custom area represented as a polygon Polygon *Polygon `json:"polygon,omitempty"` // ForceSendFields is a list of field names (e.g. "Polygon") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Polygon") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
CustomArea: Custom Area.
func (CustomArea) MarshalJSON ¶
func (s CustomArea) MarshalJSON() ([]byte, error)
type Filter ¶
type Filter struct { // LocationFilter: Required. Restricts results to places which are located in // the area specified by location filters. LocationFilter *LocationFilter `json:"locationFilter,omitempty"` // OperatingStatus: Optional. Restricts results to places whose operating // status is included on this list. If operating_status is not set, // OPERATING_STATUS_OPERATIONAL is used as default. // // Possible values: // "OPERATING_STATUS_UNSPECIFIED" - Not Specified. // "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. OperatingStatus []string `json:"operatingStatus,omitempty"` // PriceLevels: Optional. Restricts results to places whose price level is // included on this list. If price_level is not set, all price levels are // included in the results. // // Possible values: // "PRICE_LEVEL_UNSPECIFIED" - Place price level is unspecified or unknown. // "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. PriceLevels []string `json:"priceLevels,omitempty"` // RatingFilter: Optional. Restricts results to places whose average user // ratings are in the range specified by rating_filter. If rating_filter is not // set, all ratings are included in the result. RatingFilter *RatingFilter `json:"ratingFilter,omitempty"` // TypeFilter: Required. Place type filters. TypeFilter *TypeFilter `json:"typeFilter,omitempty"` // ForceSendFields is a list of field names (e.g. "LocationFilter") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "LocationFilter") to include in // API requests with the JSON null value. By default, fields with empty values // are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
Filter: Filters for the ComputeInsights RPC.
func (Filter) MarshalJSON ¶
type LatLng ¶
type LatLng struct { // Latitude: The latitude in degrees. It must be in the range [-90.0, +90.0]. Latitude float64 `json:"latitude,omitempty"` // Longitude: The longitude in degrees. It must be in the range [-180.0, // +180.0]. Longitude float64 `json:"longitude,omitempty"` // ForceSendFields is a list of field names (e.g. "Latitude") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Latitude") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
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. Values must be within normalized ranges.
func (LatLng) MarshalJSON ¶
func (*LatLng) UnmarshalJSON ¶
type LocationFilter ¶
type LocationFilter struct { // Circle: Area as a circle. Circle *Circle `json:"circle,omitempty"` // CustomArea: Custom area specified by a polygon. CustomArea *CustomArea `json:"customArea,omitempty"` // Region: Area as region. Region *Region `json:"region,omitempty"` // ForceSendFields is a list of field names (e.g. "Circle") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Circle") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
LocationFilter: Location filters. Specifies the area of interest for the insight.
func (LocationFilter) MarshalJSON ¶
func (s LocationFilter) MarshalJSON() ([]byte, error)
type PlaceInsight ¶
type PlaceInsight struct { // Place: 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). Place string `json:"place,omitempty"` // ForceSendFields is a list of field names (e.g. "Place") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Place") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
PlaceInsight: Holds information about a place
func (PlaceInsight) MarshalJSON ¶
func (s PlaceInsight) MarshalJSON() ([]byte, error)
type Polygon ¶
type Polygon struct { // Coordinates: Optional. The coordinates that define the polygon. Coordinates []*LatLng `json:"coordinates,omitempty"` // ForceSendFields is a list of field names (e.g. "Coordinates") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Coordinates") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
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).
func (Polygon) MarshalJSON ¶
type RatingFilter ¶
type RatingFilter struct { // MaxRating: Optional. Restricts results to places whose average user rating // is strictly less than or equal to max_rating. Values must be between 1.0 and // 5.0. MaxRating float64 `json:"maxRating,omitempty"` // MinRating: Optional. Restricts results to places whose average user rating // is greater than or equal to min_rating. Values must be between 1.0 and 5.0. MinRating float64 `json:"minRating,omitempty"` // ForceSendFields is a list of field names (e.g. "MaxRating") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "MaxRating") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
RatingFilter: Average user rating filters.
func (RatingFilter) MarshalJSON ¶
func (s RatingFilter) MarshalJSON() ([]byte, error)
func (*RatingFilter) UnmarshalJSON ¶
func (s *RatingFilter) UnmarshalJSON(data []byte) error
type Region ¶
type Region struct { // Place: The unique identifier of a specific geographic region. Place string `json:"place,omitempty"` // ForceSendFields is a list of field names (e.g. "Place") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Place") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
Region: A region is a geographic boundary such as: cities, postal codes, counties, states, etc.
func (Region) MarshalJSON ¶
type Service ¶
type Service struct { BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment V1 *V1Service // contains filtered or unexported fields }
func New
deprecated
New creates a new Service. It uses the provided http.Client for requests.
Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
func NewService ¶
NewService creates a new Service.
type TypeFilter ¶
type TypeFilter struct { // ExcludedPrimaryTypes: Optional. Excluded primary Place types. ExcludedPrimaryTypes []string `json:"excludedPrimaryTypes,omitempty"` // ExcludedTypes: Optional. Excluded Place types. ExcludedTypes []string `json:"excludedTypes,omitempty"` // IncludedPrimaryTypes: Optional. Included primary Place types. IncludedPrimaryTypes []string `json:"includedPrimaryTypes,omitempty"` // IncludedTypes: Optional. Included Place types. IncludedTypes []string `json:"includedTypes,omitempty"` // ForceSendFields is a list of field names (e.g. "ExcludedPrimaryTypes") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "ExcludedPrimaryTypes") to include // in API requests with the JSON null value. By default, fields with empty // values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` }
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 included_primary_types and excluded_primary_types 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 included_types and excluded_types 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 {"included_types": ["restaurant"], "excluded_primary_types": ["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 included_types and excluded_types types or included_primary_types and excluded_primary_types, an INVALID_ARGUMENT error is returned. One of included_types or included_primary_types must be set.
func (TypeFilter) MarshalJSON ¶
func (s TypeFilter) MarshalJSON() ([]byte, error)
type V1ComputeInsightsCall ¶
type V1ComputeInsightsCall struct {
// contains filtered or unexported fields
}
func (*V1ComputeInsightsCall) Context ¶
func (c *V1ComputeInsightsCall) Context(ctx context.Context) *V1ComputeInsightsCall
Context sets the context to be used in this call's Do method.
func (*V1ComputeInsightsCall) Do ¶
func (c *V1ComputeInsightsCall) Do(opts ...googleapi.CallOption) (*ComputeInsightsResponse, error)
Do executes the "areainsights.computeInsights" call. Any non-2xx status code is an error. Response headers are in either *ComputeInsightsResponse.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.
func (*V1ComputeInsightsCall) Fields ¶
func (c *V1ComputeInsightsCall) Fields(s ...googleapi.Field) *V1ComputeInsightsCall
Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more details.
func (*V1ComputeInsightsCall) Header ¶
func (c *V1ComputeInsightsCall) Header() http.Header
Header returns a http.Header that can be modified by the caller to add headers to the request.
type V1Service ¶
type V1Service struct {
// contains filtered or unexported fields
}
func NewV1Service ¶
func (*V1Service) ComputeInsights ¶
func (r *V1Service) ComputeInsights(computeinsightsrequest *ComputeInsightsRequest) *V1ComputeInsightsCall
ComputeInsights: Compute Insights RPC This method lets you retrieve insights about areas using a variaty 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.