TMaps API examples / 10

Optimized delivery route

A driver leaves the depot with several parcels. The TMaps Optimized Routing API finds the visiting order that minimizes the total time or distance, a classic traveling salesman problem. Click the map to add stops.

Click the map to add a stop (up to 50).

API request
POST https://api.tmaps.tn/routing/optimized?api_key=YOUR_API_KEY

How it works

  1. The page sends POST /routing/optimized with a fixed origin (the depot) and the waypoints to reorder.
  2. The response contains order, the zero-based indexes of the waypoints in the best visiting order: order.map(i => waypoints[i]) gives the sorted list.
  3. distance and duration are the totals for the whole tour, and legs details each segment.

Good to know

  • Up to 50 waypoints per request. Split larger lists into batches.
  • roundtrip=true brings the driver back to the origin. Set a destination to end somewhere else.
  • This version solves a single-vehicle problem without time windows or capacities.

Optimized Routing docs · Source on GitHub