Retrieve location insights

  • This tutorial demonstrates how to retrieve location metrics, such as basic insights and driving directions, using the Google My Business API.

  • Before using the API, you'll need to register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.

  • You can retrieve basic insights like direct and indirect queries for specific locations within a defined timeframe using the accounts.locations.reportInsights API.

  • Driving direction metrics, including data for the past 90 days, can also be retrieved using the accounts.locations.reportInsights API with a driving directions request.

  • Refer to the Metric reference page for a comprehensive list of supported insights available through the Google My Business API.

This tutorial shows you how to retrieve location metrics in Business Profile. 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.

Supported insights

For supported insights, see the Metric reference page.

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
POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights
{
  "locationNames": [
    "accounts/{accountId}/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
POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights
{
     "locationNames": [
             "accounts/{accountId}/locations/{locationId}"
       ],
      "drivingDirectionsRequest": {
          "numDays": "NINETY"
      }
}