This recipe follows theDocumentation Index
Fetch the complete documentation index at: https://samsara-showcase.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
/fleet/vehicles/stats/feed endpoint and writes each GPS ping to data.csv. It uses decorations to include odometer readings alongside each GPS event when available.
How it works
Use the requests and csv modules
The script uses
requests for API calls and csv to write response data in CSV format.Call /fleet/vehicles/stats/feed
The
/fleet/vehicles/stats/feed endpoint lets you follow a live feed of vehicle telematics data.Configure the Authorization header
Provide your API token in the
Authorization HTTP header. See Authentication for details.Select telematics data types
The
types parameter contains the primary stat type. This recipe uses gps.Add decorations
The
decorations parameter adds ancillary stats to the primary stat event. This recipe adds obdOdometerMeters to each GPS ping when available.Create the CSV file
The script opens
data.csv and writes headers for vehicle ID, timestamp, latitude, longitude, and odometer.Use the end cursor
The
endCursor represents the last stat event received. Pass it as after in the next request to retrieve new feed updates.