Difference between duration and duration_in_traffic in Google Directions API Response
Asked Answered
B

1

5

After working with the Google Directions API for a project I found multiple responses with a (much) shorter value in duration_in_traffic than duration. An example extract from one of the responses i got:

"duration": {
    "text": "23 mins",
    "value": 1374
},
"duration_in_traffic": {
    "text": "16 mins",
    "value": 941
},
"end_address": "2868 Mission St, San Francisco, CA 94110, USA",
"end_location": {
    "lat": 37.7522994,
    "lng": -122.4184684
},
"start_address": "O'Farrell St & Powell St, San Francisco, CA 94102, USA",
"start_location": {
    "lat": 37.78640559999999,
    "lng": -122.4082846
},

This doesn’t seem to make much sense to me, since i assumed duration is simply the duration without traffic, while duration_in_traffic obviously incorporates traffic conditions. I found an answer on a different thread, but the person answering provided no source to back up his or her claim/observation. Is there more information about the duration response field out there besides the documentation itself, which just describes it as “[indicating] the total duration of this leg”? Is there a source stating that it actually is the average time for that route? And what is the difference between duration and duration_in_traffic?

Beckmann answered 20/11, 2018 at 15:57 Comment(0)
B
10

After searching for more information about the difference between these two fields I came across this thread on the google issue tracker. There it is explained that the value in duration "takes into consideration historical data [...]", while duration_in_traffic "takes into account live traffic data in relation to your departure time". While this doesn't fully explain how the duration value is calculated, it at least extends the official documentation and confirms that historical data is used for the duration value. This also seems to be the only reliable information about the duration field on the web besides the official documentation which isn't very in depth.

Beckmann answered 3/12, 2018 at 15:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.