<br />

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:

- [Supported insights](https://developers.google.com/my-business/content/insight-data#supported-insights)
- [Basic insights](https://developers.google.com/my-business/content/insight-data#basic-insights)
- [Driving directions](https://developers.google.com/my-business/content/insight-data#driving-directions)

## 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](https://developers.google.com/my-business/content/basic-setup).

## Supported insights

For supported insights, see the [Metric](https://developers.google.com/my-business/reference/rest/v4/Metric)
reference page.

## Basic insights

Retrieves basic insights for a given list of locations. Use the [`accounts.locations.reportInsights`](https://developers.google.com/my-business/reference/rest/v4/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`](https://developers.google.com/my-business/reference/rest/v4/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"
      }
}
```