Question about API

fedingas10 days ago

I'm trying to write my own frontend, I can get all users and all devices, but I can't find how to link them. I'm currently doing it through a loop from a list of users, but it's slow and requires a lot of API requests. Is there any way to get the relationships between devices and users through the API? Or is the only way to get them directly from the database? My idea was to load the users and devices into arrays and use only them in the script.

Anton Tananaev10 days ago

Get links or set links. I'm not sure I understand what you're trying to do.

fedingas10 days ago

The API command /devices?all=true pulls out all devices, but the list does not contain any connection to the user ID. The /users command pulls out all users, but the list does not contain any connection to the device ID. In order to perform the functions I need, such as finding out how many devices a specific user has, I only have to work with the list of users, using an API query for each in a loop. Therefore, I think that maybe there is some kind of relationship table that I could access via the API, and then having three arrays in this case, I could avoid contacting the database in the script. The script will be used for user management, so there will be many queries with all the users in the system.

Anton Tananaev10 days ago

finding out how many devices a specific user

Why not use an API for that?

fedingas10 days ago

The script will be used on a different platform, not the same as the traccar server, I don't really want to open access and directly access the database. It would be easier and safer via API, but if it doesn't work via API I'll have to think of another way. So as I understand it, I can't get the links between tables via API?

Anton Tananaev10 days ago

Seems like you ignored my last comment.

fedingas10 days ago

I use it like that now, but there are not just one user, but many more, and if I create a report for all of them, it takes a long time. And this is just one of the things I need. When creating such reports, it would be much better for me to operate with arrays, rather than API queries. I hope I explained what I need. :)

Anton Tananaev10 days ago

You can't get all links via API.

fedingas10 days ago

Thanks, that's what I wanted to know. I'll think of another solution to optimize it.