Daily Duty Status Summaries

Get a summarized report of daily duty status activity for a given driver

This guide walks you through how to get a summarized report of daily duty status activity for each driver. This includes:

  • Time spent in each duty status per day
  • Distance driven per day, broken up into personal conveyance and yard moves if enabled
  • Vehicles assignments for the day
  • Trailer assignments for the day
  • Shipping doc assignments for the day
  • Log certification information

You can request an arbitrary time range (a single day, a week, a month, etc.), and the API will return summarized daily activity for each driver for each day of the time range.

The following python code shows an example of writing a CSV file where each row shows the daily distance traveled and active time of each driver.

import requests
import csv
import datetime

url = "https://api.samsara.com/fleet/hos/daily-logs"
params = {
    'startDate': '2021-01-17',
    'endDate': '2021-01-24'
}
headers = {
  'Authorization': 'Bearer <<token>>'
}

with open('daily_activities.csv', 'w') as f:
    writer = csv.DictWriter(f, ['date', 'driverId', 'driveDistanceMeters', 'activeDurationMs'])
    writer.writeheader()

    has_next_page = True
    while has_next_page:
        response = requests.request('GET', url, params=params, headers=headers).json()
        for row in response['data']:
            writer.writerow({
                'date': row['startTime'][:10],
                'driverId': row['driver']['id'],
                'driveDistanceMeters': row['distanceTraveled']['driveDistanceMeters'],
                'activeDurationMs': row['dutyStatusDurations']['activeDurationMs']
            })
        has_next_page = response['pagination']['hasNextPage']
        params['after'] = response['pagination']['endCursor']

See the Get all driver HOS daily logs reference docs for a full list of filtering parameters and response descriptions.