API directory · Google Maps Platform

Routes API: traffic-aware routing and route matrix for India

The Routes API is Google's current production routing surface, replacing the legacy Directions and Distance Matrix APIs. It covers Compute Routes for a single origin-to-destination path and Compute Route Matrix for bulk ETA calculation across up to 625 origin-destination pairs. Lepton integrates it for delivery, mobility and logistics teams across India.

Get a demo →

What the API does

Traffic-aware routing, two-wheeler mode and bulk ETA in one surface

The Routes API is the GA replacement for the legacy Directions API and Distance Matrix API. Compute Routes calculates an ideal route between an origin and destination with optional waypoints, pass-through points, alternative routes and stopover qualifiers. Compute Route Matrix returns a full distance-and-duration matrix for up to 625 origin-destination element pairs, with streaming for large matrices.

Routing modes include driving, two-wheeler, bicycling, walking and transit. Real-time traffic is available on route polylines. Toll fees are included for select cities. Eco-friendly routing by engine type is supported. Waypoint optimization reorders multi-stop routes to reduce total travel time.

Use cases

Where teams put the Routes API to work

  1. 01

    Last mile · Two-wheeler routing for Indian delivery fleets

    Two-wheeler mode applies narrow-roads and flyover logic specific to India, so routes reflect the roads bike riders actually take rather than routes optimized for four-wheelers.

  2. 02

    ETA · Live-traffic ETA for quoted arrival windows

    Real-time traffic on route polylines means the ETA your customer sees at booking reflects current congestion, not a static average, reducing missed SLAs and customer complaints.

  3. 03

    Logistics · Multi-stop optimization and bulk route matrix

    Waypoint optimization reorders delivery stops to minimize total time. Route Matrix calculates durations and distances across up to 625 origin-destination pairs in a single streaming call, for bulk dispatch and ETA grids.

  4. 04

    Tolls · Toll-cost awareness in routing

    For applicable cities, the Routes API returns toll cost alongside the route so dispatch and driver apps can factor toll spend into route selection and cost attribution.

Where Lepton comes in

Mode selection, matrix architecture and migration from legacy APIs

The Routes API is the current surface; Directions and Distance Matrix are the legacy. Teams already on the legacy endpoints need a structured migration. New integrations need mode selection (driving vs two-wheeler vs transit) and matrix sizing matched to the dispatch workload.

Migration

Structured move from Directions and Distance Matrix

We run a phased migration from the legacy APIs to the Routes API, including field mapping, quota analysis and parallel-run validation, so existing products migrate without a delivery gap.

Integration

GCP setup and SDK wiring

Service accounts, API enablement, billing configuration and Routes API call architecture delivered as a working integration, including two-wheeler mode and the correct traffic model for India.

Cost

Matrix sizing and SKU engineering

Route Matrix billing is per element pair. We size the matrix to your dispatch pattern and validate streaming call architecture so cost stays predictable as order volume grows.

Google Maps Platform · Routes API
POST directions/v2:computeRoutes · Indiranagar to Koramangala, two-wheeler
host routes.googleapis.com · auth X-Goog-Api-Key · the field mask is mandatory and it is what you are billed on
200 OK
1 route · 7.42 km

Request headers and JSON body

POST https://routes.googleapis.com/directions/v2:computeRoutes
Content-Type: application/json
X-Goog-Api-Key: <your key>
X-Goog-FieldMask: routes.distanceMeters,routes.duration,
                  routes.polyline.encodedPolyline

{
  "origin": {
    "location": { "latLng": { "latitude": 12.9784, "longitude": 77.6408 } }
  },
  "destination": {
    "location": { "latLng": { "latitude": 12.9352, "longitude": 77.6245 } }
  },
  "travelMode": "TWO_WHEELER",
  "routingPreference": "TRAFFIC_AWARE",
  "computeAlternativeRoutes": false,
  "routeModifiers": { "avoidTolls": false, "avoidHighways": false },
  "languageCode": "en-IN",
  "units": "METRIC"
}
One token carries the India argument. travelMode: TWO_WHEELER routes for a motorised two-wheeler, which is most of the delivery fleet in this country, and it takes roads a four-wheeler route would not. Switch it to DRIVE and the same pair reprices in both distance and time. routingPreference: TRAFFIC_AWARE is what makes the duration an ETA rather than an average.

Response application/json

{
  "routes": [
    {
      "distanceMeters": 7420,
      "duration": "1284s",
      "polyline": {
        "encodedPolyline": "yjmnAsxwxMR}CjAaGx@_Ef@sCXqBLoFVwM{E?"
      }
    }
  ]
}
field mask3 paths requested, 3 keys returned, nothing elsealternativescomputeAlternativeRoutes false, so 1 object in routes[]arithmetic7420 m over 1284 s is 20.8 km/h, a two-wheeler in city traffic
Fig. · One computeRoutes call, trimmed for the page. The endpoint, the headers, the request fields, the travel-mode values and every response field are the documented Routes API surface. The coordinates, distance, duration and polyline are illustrative and describe no real trip, rider or customer.
Get started

Tell us the routing problem. We will name the right surfaces.

Bring the fleet or delivery use case. We map it to the correct Routes API mode and matrix configuration and walk through the integration.

Get a demo →