Back to the blog ·

How to migrate from Google Route Optimization in an afternoon

A field-by-field checklist for moving an existing Google Route Optimization integration to the Argamin REST API: credentials, request mapping, time and load units, response handling, and a side-by-side test before you switch.

Moving a route optimization integration is less about the solver than about the plumbing around it: credentials, request shapes, time units, and how you read the answer. If your code already builds a model of vehicles and shipments, the change is mostly mechanical. This guide walks through it in the order you would do it on an afternoon.

Two things first. A Google-compatible endpoint, which would accept Google’s request format as it is, is coming soon. It is not live yet, so this guide maps your requests to the Argamin REST API you can use today. And the Google field names below are the common ones; check them against the version of Google’s documentation your code targets, because a small name can differ between versions.

1. Inventory what you send

Open the request builder in your code and list what it fills in. For most integrations the list is short:

  • vehicles, with a start and an optional end location
  • shipments with a pickup and a delivery, or plain stops
  • load quantities, with one or more dimensions
  • time windows on stops and on vehicles
  • skills, or a list of which vehicle can do which job
  • breaks, if the driver must rest
  • a time budget per stop and per vehicle

Each item has an equivalent below. If you use something that is not in the list, check it against the API reference before you assume it maps.

2. Map the request

This is the core mapping. The right-hand column is the Argamin field in POST /optimize.

Concept Google name (check your version) Argamin field in POST /optimize
Vehicle vehicles[] vehicles[]
Vehicle start and end startLocation, endLocation vehicles[].start, vehicles[].end (omit end to finish at the last stop)
Vehicle capacity loadLimits vehicles[].capacity (an array)
Shift startTimeWindows, endTimeWindows vehicles[].time_window
Driver break breakRule vehicles[].breaks
Stop that only needs a visit a shipment with a single delivery jobs[] (one entry per stop)
Shipment shipments[] with pickups and deliveries shipments[] with pickup and delivery
Location of a visit arrivalLocation location
Service time duration service (seconds)
Load at a stop loadDemands delivery or pickup (arrays)
Window for a visit timeWindows time_windows
Required skills requiredSkills skills on the stop or shipment, and on the vehicle

Three units need a deliberate change. Argamin uses plain integers for seconds and meters, so a Google duration written as a string with a trailing s must become an integer in seconds. Times are ISO 8601 strings with an offset. A location is { "lat": 51.5074, "lng": -0.1278 }; Google’s location objects use latitude and longitude, so map those two fields explicitly.

Give every stop and vehicle a stable id. Argamin responses use the ids you send, so your mapping back to your own orders stays simple.

3. Map the response

Google returns each vehicle’s route as an ordered list of visits. Argamin returns routes[] with a steps array, one step for each stop plus the start and end markers. Each step has a type (start, job, pickup, delivery, break or end), the id you sent, an arrival, and cumulative duration and distance.

Also read unassigned[]. Each entry has an id, a type (job or shipment) and a reason (TIME_WINDOW, CAPACITY, SKILL, UNREACHABLE or OTHER). Handle this list explicitly in your code. An empty list means everything was placed; a non-empty list needs an action, and it should never be silently dropped.

4. Change the credentials

Google needs a Cloud project, OAuth or a service account, and IAM roles. Argamin needs one API key:

Terminal window
curl https://api.argamin.ai/v1/optimize \
-H "Authorization: Bearer $ARGAMIN_API_KEY" \
-H "Content-Type: application/json" \
-d @request.json

Use an am_test_ key while you develop. Test keys are free and limited to 10 stops and 100 calls a day. Switch to an am_live_ key only when you are ready to bill. Keep the key on the server. Never ship it to a browser.

5. Handle retries and async work

Two things change in the way you run requests:

  • Retries. Send an Idempotency-Key header with a value of 8 to 128 characters on each optimize call. The key is kept for 24 hours. A retry with the same key and body returns the stored answer and is not billed.
  • Long problems. A synchronous call waits up to 300 seconds and accepts up to 200 stops and 20 vehicles. For bigger problems use POST /optimize/jobs, which accepts up to 1,000 stops and 100 vehicles, returns 202, and sends a signed webhook when the job finishes. Verify the signature in X-Signature as t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of <t>.<raw body> with your secret. Reject events older than five minutes.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyArgaminWebhook(rawBody, signatureHeader, secret) {
const parts = Object.fromEntries(signatureHeader.split(',').map((p) => p.split('=')));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(parts.v1 ?? '');
return a.length === b.length && timingSafeEqual(a, b);
}

Read the result with GET /optimize/jobs/{id}. The webhook payload does not include the solution itself.

6. Run both side by side

Do not switch on the first afternoon. Pick twenty real problems from your history, including the awkward ones with tight windows and full vans. Run each one through Google and through Argamin, and compare the things your business cares about: the distance, the number of vehicles used, the number of unassigned stops, and the time each call took. Use your own numbers, because your data and constraints decide the outcome, not a published figure.

Keep the Google path behind a flag for a week. Turn it off only when the comparison holds for your problems, and keep your logs for the same period.

7. Check the bill before you switch

Argamin bills per stop: each job is one stop, and a shipment’s pickup and delivery count as two stops. Google’s pricing page lists the unit it bills for each service, so take a month of your real problems, count the units in Google’s listed unit and in ours, and compare totals only after that. The pricing explainer has the tier table and a worked example.

What to do on the afternoon

  1. Write the mapping table for your own request fields (30 minutes).
  2. Change the request builder and the response reader behind a flag (1 to 2 hours).
  3. Run the twenty problems side by side and read the unassigned lists (1 hour).
  4. Set a spend cap on the account before you turn live keys on.

Join the waitlist to get access to live keys when your region opens. Coverage is listed on the coverage page, and a point outside a loaded region returns OUT_OF_COVERAGE without being billed.

Compare the cost on the pricing page, or join the waitlist.