FleetZap · Features · Solutions · FleetZap Maintenance · FleetZap Rentals · FleetZap Dispatch · FleetZap GPS Tracking · What a CMMS does · GPS tracking & engine hours · Dispatch & route optimization · Rentals module · Industries · Customers · Resources · Free calculators · Free templates · Pricing · Contact

Route optimization APIs compared: Google Maps and the alternatives

Updated · Reviewed by Israel Margulies, founder and CEO of High Point GPS

A route optimization API takes a list of stops, vehicles and rules and returns the order each vehicle should visit its stops, often with arrival times. Google offers two: waypoint ordering inside the Routes API for one vehicle, and the separate Route Optimization API for whole fleets with time windows and capacities. Mapbox, HERE and the open-source OR-Tools solver cover the same ground with different limits.

What a route optimization API does

A directions API answers one question: how do I drive from A to B, through these points, in this order? A route optimization API (route optimisation API, in British spelling) decides the order for you. With one vehicle, that is the traveling salesperson problem: visit every stop once and finish soonest. With several vehicles it becomes the vehicle routing problem, where the API also decides which truck takes which stop.

The second problem is the one most fleets have. Your dispatcher has eleven moves and three trucks, a customer who needs the machine before 9, and a trailer that can’t carry the big excavator. Ordering stops for one truck saves a few minutes. Most of the gain comes from deciding which truck takes which move without breaking a window.

Google’s two options: Routes API and Route Optimization API

Google route optimization comes in two products, and searchers mix them up. The Routes API’s Compute Routes method accepts up to 25 intermediate waypoints. Set optimizeWaypointOrder to true and it returns the best order in optimizedIntermediateWaypointIndex. Google’s documentation lists the conditions: no waypoint may be a pass-through (via) point, the routing preference can’t be TRAFFIC_AWARE_OPTIMAL, and requests that optimize waypoints are billed on a higher SKU. Requests with 11 to 25 waypoints also cost more than those with 10 or fewer. This handles one vehicle and nothing more: no time windows, no capacity, no second truck.

The Google Route Optimization API is a separate product built for fleets. You describe shipments (pickup and delivery locations, service durations, load sizes), vehicles (start and end points, capacities, travel mode), time windows, driver shifts and breaks, and costs per kilometer or per hour with penalties for missed deliveries. It returns which vehicle takes each shipment, the visit order, arrival and departure times, and total cost, distance and time. It has four endpoints: OptimizeTours for quick blocking calls, OptimizeToursLongRunning for slow solves, OptimizeToursUri for requests over 8 MB read from and written to Cloud Storage, and BatchOptimizeTours for many problems at once.

Alternatives to the Google route optimization API

Each alternative trades scope against simplicity. Check the current documentation before you build, because limits change between versions.

  • Mapbox Optimization API v1: solves the single-vehicle trip for 2 to 12 coordinates, with driving, driving-traffic, cycling and walking profiles, and a distributions parameter that forces a pickup before its paired drop-off. Mapbox lists an Optimization v2 beta that adds time windows, vehicle capacities, driver shifts and pickup and drop-off constraints.
  • HERE Tour Planning API: a vehicle routing service with synchronous and asynchronous requests. HERE says synchronous calls have stricter limits on jobs and fleet size, and recommends asynchronous calls for problems with tight time windows, many vehicle types or pickup and delivery jobs.
  • Google OR-Tools: an open-source solver library you run on your own server. You supply the distance matrix (Google suggests its Distance Matrix API as one source) and model the constraints yourself, including capacity and time windows. The default VRP example minimizes the longest single route, which suits a fleet that wants every truck home as early as possible.
  • Routes API waypoint ordering: the cheapest step up from plain directions when each driver’s stops are already decided.

What equipment moves need that parcel examples skip

Most route optimization API tutorials show vans dropping parcels, where a stop takes a minute. A lowboy delivering a dozer is a different job, and your model has to say so or the plan will look good on screen and fall apart by 10 a.m.

Model service time per stop. Chaining down a tracked machine takes far longer than handing over a box, and loading at the yard counts too. Pair pickups with drop-offs so the solver never plans the delivery before the machine is on the trailer. Give each truck its payload and give each move its weight, or let the compatibility rules keep the heavy units on the trailers rated for them. Swaps, where the driver collects a broken unit and leaves a replacement, need both halves in one route.

Then decide what the optimizer may not touch. A truck that already left the yard shouldn’t get a new stop order. A customer who agreed to a 7 a.m. drop-off should keep it even if moving them saves twenty minutes.

How to test a route optimization API before you commit

Take a real day from last month, with its moves, trucks and windows, and send the same problem to each candidate. Compare total drive time, late arrivals and the plan your best dispatcher would have made by hand. Reject any candidate whose plan breaks a trailer restriction or a promised window, even if its drive time is lower.

  • Size: the largest day you run, in stops and vehicles, fits in one request
  • Constraints: time windows, service time, capacity, paired pickups and fixed stops are all supported
  • Speed: a blocking call returns fast enough for a dispatcher waiting at the screen
  • Traffic: travel times reflect the roads trucks use at the hour they drive
  • Fallback: your app still produces a usable plan when the API is down or over quota
  • Pricing: billed per request, per vehicle or per shipment, at the volume you expect

Building on an API versus using dispatch software

The optimization call is the smallest part of a working dispatch system. Around it you need geocoded customer sites, a board where someone books and edits moves, a driver app with the run in order, arrival estimates that update, customer notifications, proof of delivery and a way to re-plan when a truck breaks down at noon. Developers who start with the API often spend most of their time on those pieces.

Build on Google’s Route Optimization API or OR-Tools if routing is your product, or your constraints are unusual enough that no packaged tool fits. If you move equipment for your own business, dispatch software that already calls a routing service is the faster path, and its API lets you plug it into the rest of your stack.

Route optimization through the FleetZap API

FleetZap’s dispatch module plans deliveries, pickups, yard transfers and shop runs. Optimize puts one driver’s run in the order that finishes soonest and keeps time windows, using Google Maps drive times; moves already under way stay put. Auto-plan shares the day’s unassigned moves among drivers and shows a preview first. Arrival estimates flag late drop-offs, long days and loads over the truck’s payload, and if Google can’t be reached FleetZap estimates drive times from straight-line distance and the average speed you set.

The same functions are in the FleetZap REST API: POST /dispatch/optimize orders a driver’s run, POST /dispatch/autoplan assigns unassigned moves (preview or apply), GET /dispatch/paths returns road paths for the day’s moves, and a dispatch_job.updated webhook fires when a move changes status. These work on moves stored in FleetZap; FleetZap isn’t a general routing API for stops from another system. You can try the endpoints with the public read-only sandbox key on the developers page.

Key takeaways

  • Before comparing prices, write down whether you need one driver’s stop order or stop assignment across trucks; the answer rules out half the products.
  • If your customers get promised drop-off windows, waypoint ordering can’t honor them; test a fleet solver instead.
  • Measure service time per stop from last month’s records (load, chain down, paperwork) and put that number in the model before you benchmark.
  • Score each candidate on late arrivals first and drive time second, using the same real day for all of them.
  • Decide the fallback before launch: who plans the day by hand, and from which screen, when the API returns an error at 6 a.m.

Free tools for this

Sources

FleetZap Dispatch

Deliveries, pickups, routing and a driver app. Explore FleetZap Dispatch.

Frequently asked questions

What is the difference between the Google Routes API and the Route Optimization API?

The Routes API computes a route for one vehicle and can reorder up to 25 intermediate stops when you set optimizeWaypointOrder. The Route Optimization API plans a whole fleet: it assigns shipments to vehicles and orders them while honoring time windows, capacities, shifts and cost settings. Use the first for a single driver’s stop order and the second for multi-vehicle dispatch.

How many stops can Google route optimization handle in one request?

The Routes API accepts up to 25 intermediate waypoints, and requests with 11 or more are billed at a higher rate. The Route Optimization API is built for bigger problems: it has long-running endpoints for slow solves and an OptimizeToursUri endpoint for requests over 8 MB stored in Cloud Storage. Check Google’s current quota pages for exact figures.

Is there a free route optimization API?

Google OR-Tools is an open-source solver you can run yourself without per-request fees, but you host it, build the distance matrix and model your constraints. Hosted APIs from Google, Mapbox and HERE charge by usage and publish their prices on their own pricing pages. Budget developer time for hosting, the distance matrix and keeping the model current.

Can a route optimization API handle time windows and truck capacity?

Some can. Google’s Route Optimization API and HERE Tour Planning support time windows and vehicle capacity, and Mapbox lists them in its Optimization v2 beta. Google’s Routes API waypoint ordering and Mapbox Optimization v1 don’t support time windows. With OR-Tools you add capacity and time-window dimensions to the model yourself.

Does FleetZap have a route optimization API?

Yes, for moves booked in FleetZap. The REST API has POST /dispatch/optimize to put a driver’s run in the best order and POST /dispatch/autoplan to share unassigned moves among drivers, with a preview option. Drive times come from Google Maps. It isn’t a general-purpose routing service for stops held in another system.

Related

Book a demo · Try the live demo