Trips
- This method returns the trip list for a vehicle within a date range.
-
Returns following information:
- StatusCode
- Message
- pagination
- Results (trip array)
-
Each item in Results contains:
- sourceId
- vehicle
- name
- driver
- startedAt
- startLocation (longitude, latitude)
- endedAt
- endLocation (longitude, latitude)
- distance
- duration
Use Case
- Use this query to obtain the trips for a vehicle within a specific date/time range.
Use an HTTP POST request to obtain the Trips list:
[POST] https://secure.trackyourtruck.com/WebApi/api/v2.2/trips
Request Header
The request header should contain the API Token obtained from the authentication process. Get Access Token.
| Header Name | Description |
|---|---|
| Authorization | API Token obtained from the authentication process. |
Request Parameters
The request should contain the following parameters:
| Parameter Name | Description | Value Format | Example |
|---|---|---|---|
| VehicleId (Optional) | Filter by a specific VehicleId. | numeric | 20768 |
| FromDateTime | Beginning Date/Time for your query. | MM/dd/yyyy hh:mm tt | 06/23/2024 12:00 AM |
| ToDateTime | Ending Date/Time for your query. | MM/dd/yyyy hh:mm tt | 07/03/2024 11:59 PM |
| PageNumber (Optional) | Page number to return. Default: 1 | numeric | 1 |
| PageSize (Optional) | Number of records per page. Default: configured server value (100). Max: 1000 | numeric | 100 |
Create Trips Request
Below is the Trips request API examples:
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer YOUR_API_TOKEN");
var values = new Dictionary<string, string>
{
{ "VehicleId", "20768" },
{ "FromDateTime", "06/23/2024 12:00 AM" },
{ "ToDateTime", "07/03/2024 11:59 PM" },
{ "PageNumber", "1" },
{ "PageSize", "100" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://secure.trackyourtruck.com/WebApi/api/v2.2/trips", content);
var responseString = await response.Content.ReadAsStringAsync();
// responseString will contain the result in JSON format
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Authorization","Bearer YOUR_API_TOKEN");
},
type: "POST",
url: "https://secure.trackyourtruck.com/WebApi/api/v2.2/trips",
dataType: "json",
data:{
VehicleId: "20768",
FromDateTime : "06/23/2024 12:00 AM",
ToDateTime: "07/03/2024 11:59 PM",
PageNumber: 1,
PageSize: 100
},
success: function(data){
// data object will contain the result as a JSON object
}
});
Sample Response
A successful request will return the following JSON result:
{
"StatusCode": "200",
"Message": "OK",
"pagination": {
"PageNumber": 1,
"PageSize": 100,
"TotalRecords": 250,
"TotalPages": 3,
"HasMore": true
},
"Results": [
{
"sourceId": 3370257017,
"vehicle": 29980,
"name": "Connor-KP2 - Demo - 092105 (Quality Increased)",
"driver": "",
"startedAt": "2025-08-25T12:09:47.613.000Z",
"startLocation": {
"longitude": -79.25365,
"latitude": 37.37022
},
"endedAt": "2025-08-25T12:16:02.000Z",
"endLocation": {
"longitude": -79.23979,
"latitude": 37.35882
},
"distance": 0.92,
"duration": "00:06:15",
"Media": [
{
"Type": "Image",
"Url": "https://...jpg",
"Camera": "Forward Facing",
"EventTime": "2025-08-25T12:16:43.000Z",
"Event": "Shock"
},
{
"Type": "Image",
"Url": "https://...jpg",
"Camera": "Driver Facing",
"EventTime": "2025-08-25T12:16:43.000Z",
"Event": "Shock"
},
{
"Type": "Video",
"Url": "https://....mp4",
"Camera": "Forward Facing",
"EventTime": "2025-08-25T12:16:43.000Z",
"Event": "Distracted Driving",
"PosterUrl": "https://...jpg"
},
{
"Type": "Video",
"Url": "https://...mp4",
"Camera": "Driver Facing",
"EventTime": "2025-08-25T12:16:43.000Z",
"Event": "Distracted Driving",
"PosterUrl": "https://...jpg"
}
]
}
]
}
Test
Test the Trips API using your AccessToken by entering it below:
Clicking the test button will send a request to the TYT API and display the result below.