Dear all,
I need to get the latest position of a specific device using Javascript (AJAX).
Following the API I tried to get devices positions from url "api/positions" and "api/positions/get?" with id - from - to parameters - but I don't want to get it in this way because sometimes I don't know the correct date/time and I don't want to call other API to know it.
My question is: Is there a way to get the latest position (lat,lon) of a single device ID via AJAX? Is there a specific URL?
Here's my code - but in any case I get all the devices and I just know to get ID 13 (for example):
$.ajax({
type: 'get',
url: 'http://151.0.212.44:8082/api/positions/',
headers: {
"Authorization": "Basic " + btoa("username" + ":" + "pwd")
},
contentType:"application/json",
data:JSON.stringify({
name:"Name",
deviceId:"13"
}),
success: function (response) {
console.log(response);
latitude = response[0]["latitude"];
longitude = response[0]["longitude"];
}
});
You can't get latest for any specific device, but you can get latest for all your devices if you don't include parameters. By the way, if you use parameters in some other call, they should be passed as query params, not JSON.
Please check Traccar API documentation:
https://www.traccar.org/traccar-api/
Is there an API to get single device details like https://demo4.traccar.org/api/devices/{id}
Dear all,
I need to get the latest position of a specific device using Javascript (AJAX).
Following the API I tried to get devices positions from url "api/positions" and "api/positions/get?" with id - from - to parameters - but I don't want to get it in this way because sometimes I don't know the correct date/time and I don't want to call other API to know it.
My question is: Is there a way to get the latest position (lat,lon) of a single device ID via AJAX? Is there a specific URL?
Here's my code - but in any case I get all the devices and I just know to get ID 13 (for example):