Get an eco-friendly route

By default, the Routes API returns the default route, meaning a route without factoring in fuel or energy-efficiency. When you enable eco-friendly routing, you still get the default route in the response. In addition, you also get back an eco-friendly route showing the most fuel- or energy-efficient route based on your vehicle's engine type.

The eco-friendly route returned by the Routes API is optimized for lower fuel consumption over the entire route. The API uses your vehicle's engine type along with other factors such as real-time traffic and road conditions to choose the eco-friendly route. The more fuel or energy-efficient the route, the lower your car's fuel/energy usage and CO2 emissions.

For example, a diesel vehicle's relative fuel economy advantage is generally greatest in highway driving. Hybrid and electric vehicles tend to provide progressively greater efficiency in stop-and-go city driving and hilly driving environments where they can extensively use and benefit from regenerative braking.

You can also request that the API returns the estimated fuel consumption for the entire route. Use the fuel consumption estimates as a way to compare different routes, not as explicit fuel usage estimates for your exact vehicle.

How Google Maps estimates fuel efficiency

The Routes API estimates fuel-efficiency using insights from the US Department of Energy's National Renewable Energy Laboratory and data from the European Environment Agency. This calculation includes factors that affect your fuel and energy usage and CO2 emissions, such as:

  • Average fuel or energy consumption for vehicles in your region
  • Steepness of hills on your route
  • Stop-and-go traffic patterns
  • Types of roads (such as local roads or highways)

The Routes API returns the most fuel or energy-efficient route when it has roughly the same arrival time as the default route. In cases where fuel or energy savings are too small or increase driving time significantly, the API shows relative fuel or energy savings between routes to help you compare.

Read more about eco-friendly routing technology (PDF).

Prerequisites

To use eco-friendly routing or estimate fuel consumption:

  • You must specify TRAFFIC_AWARE_OPTIMAL as the routing preference. In this mode, the server performs a more exhaustive search of the road network to find the optimal route. For more information, see Configure quality vs latency.

  • You must set travelMode to DRIVE. Requests for any other travel mode return an error.

  • You must set a location for the origin waypoint in a supported region. Otherwise, the API returns an error.

  • The route cannot contain an intermediate waypoint.

Billing

Typically, Google Maps Platform does not charge for the use of a Preview feature. However, because eco-friendly routing and estimating fuel consumption requires that you specify TRAFFIC_AWARE_OPTIMAL as the routing preference, you are charged based on the SKU: Routes Advanced.

Learn more about billing for Routes API.

Request an eco-friendly route

To make a request to compute an eco-friendly route, set the following properties in the request:

  • Specify emissionType for the vehicle using the values defined in VehicleEmissionType: DIESEL, GASOLINE, ELECTRIC, or HYBRID. The default value is GASOLINE.

  • Set requestedReferenceRoutes to FUEL_EFFICIENT.

  • Set a response field mask that specifies to return the response properties associated with an eco-friendly route:

    • routes.routeLabels: Identifies each route as either DEFAULT_ROUTE, FUEL_EFFICIENT, or DEFAULT_ROUTE_ALTERNATE.

    • routes.routeToken: A route token that you can pass to the Navigation SDK to retrieve a custom route.

Example eco-friendly request

The following code shows a request for an eco-friendly route. In this example, you use the response field mask to return response properties associated with an eco-friendly route along with the routes.distanceMeters and routes.duration properties:

curl -X POST -H 'content-type: application/json' -d '{
  "origin": {
    "location": {
      "latLng": {
        "latitude": 41.76904801292959,
        "longitude": -72.67374935684933
      }
    }
  },
  "destination": {
    "location": {
      "latLng": {
        "latitude": 41.823042361105024,
        "longitude": -71.40933143059424
      }
    }
  },
  "routeModifiers": {
    "vehicleInfo": {
      "emissionType": "GASOLINE"
    }
  },
  "travelMode":"DRIVE",
  "routingPreference": "TRAFFIC_AWARE_OPTIMAL",
  "requestedReferenceRoutes": ["FUEL_EFFICIENT"]
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.distanceMeters,routes.duration,routes.routeLabels,routes.routeToken' \
'https://routes.googleapis.com/directions/v2:computeRoutes'

Example eco-friendly response

The computeRoutes call above generates a JSON response that contains two routes: the default route and the fuel efficient route. In the response:

  • For the default route, the routeLabels array property contains DEFAULT_ROUTE.

  • For the eco-friendly route, the routeLabels array property contains FUEL_EFFICIENT.

  • If you set computeAlternativeRoutes in the request to true to calculate alternate routes, the routeLabels array property contains DEFAULT_ROUTE_ALTERNATE.

{
    "routes": [
        {
            "distanceMeters": 138939,
            "duration": "5412s",
            "routeToken": "CoYJCpoIC…0n9S1cu",
            "routeLabels": [
                "DEFAULT_ROUTE"
            ]
        },
        {
            "distanceMeters": 116887,
            "duration": "5631s",
            "routeToken": "CuEHCu0G…xqm",
            "routeLabels": [
                "FUEL_EFFICIENT"
            ]
        }
    ]
}

Because of current driving conditions and other factors, the default route and the eco-friendly route can be the same. In this case, routeLabels contains both labels: DEFAULT_ROUTE and FUEL_EFFICIENT:

{
  "routes": [
    {
      "distanceMeters": 45875,
      "duration": "2655s",
      "routeToken": "CvcDCos…6I40",
      "routeLabels": [
        "DEFAULT_ROUTE",
        "FUEL_EFFICIENT"
      ]
    }
  ]
}

Estimate fuel usage for the route

You can request the method to return the estimated fuel usage for the entire route, in microliters. To add the estimated fuel usage for a route to the response:

  • Set the extraComputations array field to FUEL_CONSUMPTION to enable the fuel usage calculation.

  • Specify emissionType for the vehicle using the values defined in VehicleEmissionType: DIESEL, GASOLINE, ELECTRIC, or HYBRID. The default value is GASOLINE.

    If the emissionType is HYBRID, the API converts electricity and fuel consumption to microliters of fuel.

    If the emissionType is ELECTRIC, the API converts electricity consumption to microliters of fuel.

  • Set a response field mask that specifies to return the response properties associated with fuel usage: routes.travelAdvisory.fuelConsumptionMicroliters.

The following example requests estimated fuel usage as part of a request that also includes the eco-friendly route:

curl -X POST -H 'content-type: application/json' -d '{
  "origin": {
    "location": {
      "latLng": {
        "latitude": 41.76904801292959,
        "longitude": -72.67374935684933
      }
    }
  },
  "destination": {
    "location": {
      "latLng": {
        "latitude": 41.823042361105024,
        "longitude": -71.40933143059424
      }
    }
  },
  "routeModifiers": {
    "vehicleInfo": {
      "emissionType": "GASOLINE"
    }
  },
  "travelMode":"DRIVE",
  "routingPreference": "TRAFFIC_AWARE_OPTIMAL",
  "extraComputations": ["FUEL_CONSUMPTION"],
  "requestedReferenceRoutes": ["FUEL_EFFICIENT"]
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.distanceMeters,routes.duration,routes.routeLabels,routes.routeToken,routes.travelAdvisory.fuelConsumptionMicroliters' \
'https://routes.googleapis.com/directions/v2:computeRoutes'

The response contains the estimated fuel consumption for both the default route and for the eco-friendly route:

{
    "routes": [
        {
            "distanceMeters": 138939,
            "duration": "5412s",
            "travelAdvisory": {
                "fuelConsumptionMicroliters": "11019554"
            },
            "routeToken": "CoYJCpoIC…0n9S1cu",
            "routeLabels": [
                "DEFAULT_ROUTE"
            ]
        },
        {
            "distanceMeters": 116887,
            "duration": "5631s",
            "travelAdvisory": {
                "fuelConsumptionMicroliters": "9572436"
            },
            "routeToken": "CuEHCu0G…xqm",
            "routeLabels": [
                "FUEL_EFFICIENT"
            ]
        }
    ]
}

Supported regions

The Google Maps Platform team is constantly working to improve international coverage for our API services. The following list shows the latest coverage details, on a country-by-country basis, for eco-friendly routing:

  • Albania (AL)
  • Austria (AT)
  • Belgium (BE)
  • Bosnia and Herzegovina (BA)
  • Bulgaria (BG)
  • Canada (CA)
  • Croatia (HR)
  • Cyprus (CY)
  • Czechia (CZ)
  • Denmark (DK)
  • Estonia (EE)
  • Finland (FI)
  • France (FR)
  • Germany (DE)
  • Greece (GR)
  • Hungary (HU)
  • Iceland (IS)
  • Ireland (IE)
  • Italy (IT)
  • Kosovo (XK)
  • Latvia (LV)
  • Liechtenstein (LI)
  • Lithuania (LT)
  • Luxembourg (LU)
  • Malta (MT)
  • Montenegro (ME)
  • Netherlands (NL)
  • North Macedonia (MK)
  • Norway (NO)
  • Poland (PL)
  • Portugal (PT)
  • Romania (RO)
  • Serbia (RS)
  • Slovakia (SK)
  • Slovenia (SI)
  • Spain (ES)
  • Sweden (SE)
  • Switzerland (CH)
  • Turkey (TR)
  • United Kingdom (GB)
  • United States (US)