Stay organized with collections
Save and categorize content based on your preferences.
European Economic Area (EEA) developers
Traffic models use specific algorithms and factors to predict how traffic
conditions impact total travel time for a given route. The Routes API
offers different traffic model types to prioritize different factors used in
calculating duration in traffic. You can specify the traffic model type you'd
like your routes to use when calculating the duration for your routes or route
matrix. When you set the traffic model type, the value returned in the
duration field varies depending on the traffic model you choose.
Both the Routes API Compute Routes and
Compute Route Matrix methods support traffic model types.
By default, both methods use the BEST_GUESS traffic model type.
To specify a traffic type
Set your origin and destination.
If your departure time is in the future, include the time using the
departure_time parameter. If you don't specify a departure time, it
defaults to now.
Set the routingPreference parameter to TRAFFIC_AWARE_OPTIMAL. Setting the
routingPreference to TRAFFIC_UNAWARE or TRAFFIC_AWARE is incompatible
with the trafficModel parameter.
Select the traffic model to use with the trafficModel parameter and
one of the following types:
BEST_GUESS (default) to request that the returned duration_in_traffic
is the best estimate of travel time given what is known about both
historical traffic conditions and live traffic. Live traffic becomes more
important the closer the departure_time is to now. Using the default type
of BEST_GUESS gives the most useful predictions for the vast majority of
use cases.
PESSIMISTIC to request that the returned duration_in_traffic models the
time based on the historical traffic conditions on bad traffic days.
This type gives an estimated duration that is most likely longer than
the actual travel time on most days. Occasional days with particularly bad
conditions may still exceed this estimate.
OPTIMISTIC to request that the returned duration_in_traffic models the
time based on the historical traffic conditions on good traffic days.
This type gives an estimated duration that is most likely shorter than
the actual travel time on most days. Occasional days with particularly
good conditions may still be faster than this estimate.
For example:
"trafficModel":"OPTIMISTIC"
Specify the routes.duration field in the field mask.
REST
-HX-Goog-FieldMask:routes.duration
RPC
const(fieldMask="routes.duration")
When the Routes API estimates time in traffic, it uses the traffic
model type you've requested.
Example: Traffic model request
For example, this request specifies that the duration be estimated using the
OPTIMISTIC traffic model type at a specific departure time:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[[["\u003cp\u003eThe Routes API offers different traffic models (\u003ccode\u003eBEST_GUESS\u003c/code\u003e, \u003ccode\u003ePESSIMISTIC\u003c/code\u003e, \u003ccode\u003eOPTIMISTIC\u003c/code\u003e) to predict travel times based on various traffic conditions.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify the desired traffic model when calculating routes, with \u003ccode\u003eBEST_GUESS\u003c/code\u003e being the default, providing the most useful predictions for most use cases.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePESSIMISTIC\u003c/code\u003e models travel time based on bad traffic days, likely resulting in a longer estimated duration, while \u003ccode\u003eOPTIMISTIC\u003c/code\u003e uses good traffic days, potentially resulting in a shorter duration.\u003c/p\u003e\n"],["\u003cp\u003eLive traffic information is integrated into the \u003ccode\u003eBEST_GUESS\u003c/code\u003e model, making it potentially shorter than \u003ccode\u003eOPTIMISTIC\u003c/code\u003e or longer than \u003ccode\u003ePESSIMISTIC\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo use traffic models, include the \u003ccode\u003etrafficModel\u003c/code\u003e parameter in your request and specify \u003ccode\u003eroutes.duration\u003c/code\u003e in the field mask.\u003c/p\u003e\n"]]],["The Routes API's traffic models predict travel time, offering `BEST_GUESS` (default), `PESSIMISTIC` (longer), and `OPTIMISTIC` (shorter) durations. To use, set the origin, destination, and optional `departure_time`. Choose a `trafficModel` type and specify `routes.duration` in the field mask. The API calculates traffic-affected durations based on the selected model. Using `BEST_GUESS` integrate live information. The default is `BEST_GUESS`, and the duration returned varies depending on the chosen model. The service is pre-GA, it might have limited support and changes.\n"],null,[]]