Calculate toll fees for a route matrix

  • The Routes API's computeRouteMatrix method allows you to calculate estimated toll fees for routes in supported cities, providing cost insights for route planning.

  • To enable toll calculations, specify TOLLS in the extraComputations field and provide vehicle and toll pass details in the routeModifiers field within the request.

  • Toll prices are estimates and are influenced by factors like vehicle type and toll pass used, with the response including the estimated price in the specified currency.

  • While the Route Matrix provides toll information, detailed route specifics are not included; for that, use the Compute Routes functionality with single origin and destination points.

  • Be aware that requests including toll fee calculations are billed at a higher rate than standard route matrix requests.

European Economic Area (EEA) developers

When you are computing a route matrix, you might want to take into consideration any toll fees on the routes in the matrix. For select cities, you can compute the estimated toll fee for a route in the appropriate currency.

To get tolls for a route, see Calculate tolls fees for a route.

For the list of supported toll locations, see the reference for TollPass.

Route matrix toll example

The following example uses the computeRouteMatrix method to return toll information on a route with an estimated price when a toll pass is used:

  • Set the extraComputations array field to TOLLS to enable the calculation of toll information.

  • Specify the vehicle type and the toll pass type by using the routeModifiers field of the origin waypoints of the request. The toll price returned is based on the pricing used by the specified vehicle type and pass. If more than one pass is specified, the least expensive pricing is returned.

  • Use the response field mask to configure the method to return toll information in the response. Specify routes.travelAdvisory.tollInfo to return information for the entire route.

Request for a route matrix toll information

curl -X POST -d '{
"origins": [
  {
    "waypoint": {
      "location": {
        "latLng": {
          "latitude":42.340173523716736,
          "longitude":-71.05997968330408
        }
      }
    },
    "routeModifiers": {
      "vehicleInfo":{
        "emissionType": "GASOLINE"
      },
      "tollPasses": [
        "US_MA_EZPASSMA",
        "US_WA_GOOD_TO_GO"
      ]
    }
  }
],
"destinations": [
  {
    "waypoint": {
      "location": {
        "latLng": {
          "latitude":42.075698891472804,
          "longitude": -72.59806562080408
        }
      }
    }
  }
],
"travelMode": "DRIVE",
"extraComputations": ["TOLLS"]
}' \
-H 'Content-Type: application/json' \
-H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: originIndex,destinationIndex,travel_advisory.tollInfo,duration,distanceMeters,status' \
'https://routes.googleapis.com/distanceMatrix/v2:computeRouteMatrix'

Response for route matrix toll information

The response contains information on tolls in a TollInfo (REST) or TollInfo (gRPC) object.

To configure the method to return toll information, use the response field mask to set the travelAdvisory.tollInfo field in the mask.

[
  {
    "originIndex": 0,
    "destinationIndex": 0,
    "status": {},
    "distanceMeters": 150338,
    "duration": "5382s",
    "travelAdvisory": {
      "tollInfo": {
        "estimatedPrice": [
          {
            "currencyCode": "USD",
            "units": "4",
            "nanos": 400000000
           }
        ]
      }
    }
  }
]