LastLocation
- This method contains the Last Known Location of the vehicle with Date & Time
-
Returns one piece of information:
- Last Known Vehicle Location with the Location, Date & Time
Use Case
- Use to query latest Vehicle Location with Location, Date, Time
Use an HTTP GET request to obtain your vehicle's Last Location:
[GET] https://secure.trackyourtruck.com/WebApi/api/v2.1/LastLocation/{Vehicle_ID}?IsUtcTimeZone={IsUtcTimeZone}
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 1st step's authentication process. |
URL Parameter
If you want to receive the Last Known Vehicle Location for a specific vehicle, the URL should contain the VehicleID parameter below.
Parameter Name | Description | Value Format | Example |
---|---|---|---|
Vehicle ID (Optional) | To get the Last Location of a specific vehicle. | numeric | 825 |
IsUtcTimeZone (optional) |
"True" returns Event Time in UTC "False"/"Blank" returns Event Time in Vehicle Time Zone |
true or false | true |
Create LastLocation Object
Below is the LastLocation request API examples:
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer YOUR_API_TOKEN")
var response = await client.GetAsync("https://secure.trackyourtruck.com/WebApi/api/v2.1/LastLocation");
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: "GET",
url: "https://secure.trackyourtruck.com/WebApi/api/v2.1/LastLocation",
dataType: "json",
success: function(data){
//data object will contain the result as a JSON object
}
});
Sample LastLocation Object
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Authorization","Bearer YOUR_API_TOKEN");
},
type: "GET",
url: "https://secure.trackyourtruck.com/WebApi/api/v2.1/LastLocation",
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",
"Data":[
{
"VehicleId": 15818,
"VehicleName": "Alison-4509",
"TimeZone": "EST",
"ReasonCode": "44",
"Lat": 37.41,
"Lon": -79.31655,
"MoveTime": "07/20/2020 21:31:56",
"Address1": "1214 Lakepointe Dr",
"City": "Forest",
"State": "VA",
"Zip": "24551",
"Speed": "0.000",
"Course": "22.000"
},
{
"VehicleId": 15879,
"VehicleName": "Robbie Jr- 2013 Camry (33.10)",
"TimeZone": "EST",
"ReasonCode": "5",
"Lat": 37.40994,
"Lon": -79.31647,
"MoveTime": "07/20/2020 21:33:44",
"Address1": "1214 Lakepointe Dr",
"City": "Forest",
"State": "VA",
"Zip": "24551",
"Speed": "0.000",
"Course": "88.000"
},
{
"VehicleId": 17646,
"VehicleName": "Samar-CRV",
"TimeZone": "CST",
"ReasonCode": "2",
"Lat": 41.89564,
"Lon": -87.8004,
"MoveTime": "07/20/2020 16:58:19",
"Address1": "536 Forest Ave",
"City": "Oak Park",
"State": "IL",
"Zip": "60302",
"Speed": "0.000",
"Course": "88.000"
},
.............
.............
.............
]
}
Test
Test the LastLocation using your AccessToken by entering it below:
Clicking the test button will send a request to the TYT API and display the result below.