Route Optimization API quick reference

The Route Optimization API assigns tasks and routes to a vehicle fleet, optimizing against the objectives and constraints you supply, such as time windows, vehicle capacity, driver hours, and costs. You call it through REST, gRPC, or client libraries, and it returns visit sequences, shipment assignments, estimated times, and route metrics.

Route Optimization API: key facts

  • Product: Route Optimization API
  • Also known as: GMPRO
  • Category: Routes
  • Platform: Web service (REST)
  • Runs on: Server (backend code)
  • Launch stage: GA
  • Lifecycle: Active
  • Overview: Route Optimization API overview

Route Optimization API: when to use it

Use Route Optimization API when:

  • You need to assign shipments or tasks to several vehicles while respecting time windows, vehicle capacity, driver hours, and costs.
  • You need the best stop sequence for one vehicle with several pickups, deliveries, or appointments.
  • You need to re-optimize active routes for new orders (such as on-demand dispatch) using injectedFirstSolutionRoutes or injectedSolutionConstraint.
  • You need route tokens for each leg of an optimized plan to pass to the Navigation SDK.

Don't use Route Optimization API when:

  • You need live tracking of how drivers execute the plan; the API returns planned polylines, not real-time vehicle routes. Use Fleet Engine Service instead.
  • You need in-app turn-by-turn guidance for drivers along the optimized route. Use Navigation SDK for Android instead.
  • You need in-app turn-by-turn guidance for drivers on iOS along the optimized route. Use Navigation SDK for iOS instead.

Route Optimization API: setup

Official Route Optimization API packages:

  • npm: @googlemaps/routeoptimization
  • pypi: google-maps-routeoptimization
  • go: cloud.google.com/go/maps
  • maven: com.google.maps:google-maps-routeoptimization

Route Optimization API: common mistakes

  • Problem: For REST calls to the blocking OptimizeTours endpoint, the default 60-second deadline overrides any request-body timeout larger than 60 seconds. Fix: Set the X-Server-Timeout header (seconds, no "s" suffix) to extend the deadline. Client libraries and gRPC default to 3600 seconds. See /maps/documentation/route-optimization/timeouts.
  • Problem: timeout and deadline values are capped at 1800 seconds. Fix: Set allowLargeDeadlineDespiteInterruptionRisk to true to allow up to 3600 seconds, accepting a higher risk of interruption errors. See /maps/documentation/route-optimization/timeouts.
  • Problem: Without cost parameters (for example costPerHour or costPerKilometer), the optimizer treats all solutions as equal. Fix: Define cost parameters on vehicles that reflect your business costs. See /maps/documentation/route-optimization/make-first-request.
  • Problem: Requests authenticated with an API key fail; every request needs an OAuth token. Fix: Use an OAuth token with the https://www.googleapis.com/auth/cloud-platform scope, for example through Application Default Credentials or a service account. See /maps/documentation/route-optimization/cloud-setup#create-an-oauth-token.

What you can do with Route Optimization API

See the guides linked below for each task, or compare across products in the Capabilities Explorer.