Retrieve location insights

This tutorial shows you how to retrieve location metrics in Google My Business. The Google My Business API provides you with the ability to work with location metrics to retrieve the following types of data:

Before you begin

Before you use the Google My Business API, you need to register your application and obtain OAuth 2.0 credentials. For details on how to get started with the Google My Business API, see Basic setup.

Basic insights

Retrieves basic insights for a given list of locations. Use the accounts.locations.reportInsights API to return the insights that are associated with a location.

To return the basic insights associated with a location, use the following:

HTTP

To get basic insights, send a POST request with a URL and request body of the following form:

POST https://mybusiness.googleapis.com/v4/account_name/locations:reportInsights

{
  "locationNames": [
    “accounts/account_name/locations/locationId”,
  ],
  “basicRequest” : {
          "metricRequests": [
             {
               "metric": QUERIES_DIRECT,
             },
             {
               "metric": QUERIES_INDIRECT,
             }
          ],
          "timeRange": {
               "startTime": 2016-10-12T01:01:23.045123456Z,
               "endTime": 2017-01-10T23:59:59.045123456Z,
          },
    },
}

Driving directions

Retrieves driving direction metrics for a given list of locations. Use the accounts.locations.reportInsights API to return driving direction metrics that are associated with a location.

To return the driving direction metrics, use the following:

HTTP

To get driving direction metrics, send a POST request with a URL and request body of the following form:

POST https://mybusiness.googleapis.com/v4/account_name/locations:reportInsights

{
     “locationNames": [
             “accounts/account_name/locations/locationId”,
       ],
      "drivingDirectionsRequest”: {
            "numDays": NINETY,
      },
}