HistoricalVehicleLocations
- This method returns historical vehicle location records
-
Returns the following data:
- vehicle
- locatedAt (UTC timestamp)
- location.longitude
- location.latitude
- sourceId
- driver
- address.formatted
- heading
- speed
Use Case
- Use to retrieve historical vehicle location history
Use an HTTP POST request to obtain historical vehicle locations:
[POST] https://secure.trackyourtruck.com/WebApi/api/v2.2/HistoricalVehicleLocations
Request Header
The request header should contain the API Access Token obtained from the authentication process. Get Access Token.
| Header Name | Description |
|---|---|
| Authorization | Access Token obtained from the 1st step's authentication process. |
Request Parameters
The Request should contain the following parameters:
| Parameter Name | Description | Value Format | Example |
|---|---|---|---|
| FromDateTime (Required) | Beginning Date/Time for your query* | MM/dd/yyyy hh:mm tt | 08/01/2018 12:00 AM |
| ToDateTime (Required) | Ending Date/Time for your query* | MM/dd/yyyy hh:mm tt | 08/30/2018 11:59 PM |
| TruckId (Required) | Required truck identifier to filter locations for a specific vehicle | numeric | 825 |
| 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 |
* The date/time range between FromDateTime and ToDateTime cannot exceed 30 days.
Create HistoricalVehicleLocations Object
Below is the HistoricalVehicleLocations request API examples:
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer YOUR_API_TOKEN")
var content = new FormUrlEncodedContent(new []
{
new KeyValuePair<string, string>("FromDateTime", "08/01/2018 12:00 AM"),
new KeyValuePair<string, string>("ToDateTime", "08/30/2018 11:59 PM"),
new KeyValuePair<string, string>("TruckId", "825"),
new KeyValuePair<string, string>("PageNumber", "1"),
new KeyValuePair<string, string>("PageSize", "100")
});
var response = await client.PostAsync("https://secure.trackyourtruck.com/WebApi/api/v2.2/HistoricalVehicleLocations", content);
var responseString = await response.Content.ReadAsStringAsync();
//responseString will contain the response 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/HistoricalVehicleLocations",
data: {
FromDateTime: "08/01/2018 12:00 AM",
ToDateTime: "08/30/2018 11:59 PM",
TruckId: 825,
PageNumber: 1,
PageSize: 100
},
dataType: "json",
success: function(data){
//data object will contain the result as a JSON object
}
});
Sample HistoricalVehicleLocations Object
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Authorization","Bearer YOUR_API_TOKEN");
},
type: "POST",
url: "https://secure.trackyourtruck.com/WebApi/api/v2.2/HistoricalVehicleLocations",
data: {
FromDateTime: "08/01/2018 12:00 AM",
ToDateTime: "08/30/2018 11:59 PM",
TruckId: 825,
PageNumber: 1,
PageSize: 100
},
dataType: "json",
success: function(data){
//data object will contain the result as a JSON object
}
});
A successful request will return the following JSON result:
{
"StatusCode": "200",
"Message": "OK",
"pagination": {
"PageNumber": 1,
"PageSize": 100,
"TotalRecords": 1250,
"TotalPages": 13,
"HasMore": true
},
"results": [
{
"vehicle": "8566",
"locatedAt": "2025-01-06T03:24:53.000Z",
"location": {
"longitude": -122.4194155,
"latitude": 37.7749295
},
"sourceId": "123456789",
"driver": "563",
"address": {
"formatted": "630 Wyndhurst Dr, Lynchburg, VA 24502"
},
"heading": 25,
"speed": 95.33,
"Media": [
{
"Type": "Image",
"Url": "https://...jpg",
"Camera": "Forward Facing",
"EventTime": "2025-08-23T15:09:00.000Z",
"Event": "Shock"
},
{
"Type": "Image",
"Url": "https://...jpg",
"Camera": "Driver Facing",
"EventTime": "2025-08-23T15:09:00.000Z",
"Event": "Shock"
},
{
"Type": "Video",
"Url": "https://...mp4",
"Camera": "Forward Facing",
"EventTime": "2025-06-16T12:05:39.000Z",
"Event": "Distracted Driving",
"PosterUrl": "https://...jpg"
},
{
"Type": "Video",
"Url": "https://...mp4",
"Camera": "Driver Facing",
"EventTime": "2025-06-16T12:05:39.000Z",
"Event": "Distracted Driving",
"PosterUrl": "https://...jpg"
}
]
},
{
"vehicle": "8567",
"locatedAt": "2025-01-06T03:26:10.000Z",
"location": {
"longitude": -97.7430608,
"latitude": 30.267153
},
"sourceId": "987654321",
"driver": "564",
"address": {
"formatted": "2215 Memorial Ave, Lynchburg, VA 24501"
},
"heading": 120,
"speed": 62.45,
"Media": []
}
]
}
Test
Test the HistoricalVehicleLocations using your AccessToken by entering it below:
Clicking the test button will send a request to the TYT API and display the result below.