I am using the following code to access data for a specific device on Traccar GPS using Taccar API.
import pytraccar.api as api
test_url = 'http://localhost:8082'
username, password = 'admin', 'admin'
url_positions = 'http://localhost:8082/api/positions'
user = api.TraccarAPI(base_url=test_url)
result = user.login_with_credentials(username, password)
device = user.get_devices(query='uniqueId', params=['12345'])
assert type(result) == dict
assert type(device) == list
print(device[0]["positionId"])
By using this code I am able to print the last device (12345) position. The result is an integer.
How can I get the latitude and longitude for this position?
EDIT: I am using this traccar api: https://github.com/ludeeus/pytraccar
PM
I solved my problem using a sample code provided by the developer.
The sample code:
This returns several dictionaries and one of them is "data.positions". Using this specific dictionary I am able to manage it and get the results I need.