How to Include Traffic in Route Time Calculations

API or service
Routing API
Task
Waypoints and traffic model → route time estimate
Examples
URL
Difficulty
Beginner
Time
7 min

Include traffic in route time calculations

You need a travel-time estimate that accounts for roads that are commonly slower under congestion. The Routing API traffic parameter controls the speed model used to select the route and calculate its duration.

Geoapify provides free-flow and approximated traffic models. Approximated traffic is not a live traffic feed and does not describe the conditions at a specific departure time.

Task flow: waypoints and traffic model → Routing API → selected route and estimated duration.

Choose a traffic model

Value Behavior Use when
free_flow Assumes uncongested roads and optimistic speeds. This is the default. You need a stable baseline or best-case travel time.
approximated Reduces speeds on roads that are likely to experience congestion. You need a more conservative general estimate for a motorized route.

The traffic model applies to motorized modes such as drive and truck modes. It can change both the estimated time and the selected route because a normally fast road may become less attractive under approximated speeds.

Compare route times

Calculate the free-flow route across San Francisco:

https://api.geoapify.com/v1/routing?waypoints=37.7749,-122.4194|37.7936,-122.3965&mode=drive&traffic=free_flow&format=json&apiKey=YOUR_API_KEY

Repeat the request with approximated traffic:

https://api.geoapify.com/v1/routing?waypoints=37.7749,-122.4194|37.7936,-122.3965&mode=drive&traffic=approximated&format=json&apiKey=YOUR_API_KEY

Reduced response comparison:

{
  "free_flow": {
    "distance": 5995,
    "time": 481.561
  },
  "approximated": {
    "distance": 3527,
    "time": 1469.904
  }
}

The free-flow result is about 8 minutes, while the approximated result is about 24.5 minutes. The distances also differ because the model selected a different route; traffic does not merely add a delay to an unchanged geometry.

Use traffic estimates correctly

Present the result as an estimate based on the selected traffic model. Do not label approximated as “live traffic” or imply that it includes current incidents.

  • Use the same traffic model when comparing several routes or matrix cells.
  • Store the model alongside a cached duration so consumers know how it was calculated.
  • Recalculate when waypoints, travel mode, avoid rules, or the traffic model changes.
  • Convert time, returned in seconds, into display units without discarding the original value.
  • Calculate an arrival timestamp in your application by adding the returned duration to the chosen departure time.
  • Keep uncertainty visible when travel-time accuracy affects dispatching or customer promises.

For many origins or destinations, use the Route Matrix API with the same traffic value instead of sending a separate Routing API request for every pair.