Getting speed/distance units via API

alexbk664 years ago

I get that the measurement units are reported in User Attributes, but I can't find how to get the current User?

Anton Tananaev4 years ago

Session endpoint.

alexbk664 years ago

Thank you Anton

alexbk664 years ago

Hmm

Execute(sync)[http://demo.traccar.org/api/session]: The remote server returned an error: (404) Not Found. 
Anton Tananaev4 years ago

That means you are not logged in.

alexbk664 years ago

It works in browser, but via API returns 404. But other calls work (server, devices, geofences, etc)

alexbk664 years ago

And even in browser Attributes are empty:

{"id":1520,"attributes":{},"name":"alexbk66",
Anton Tananaev4 years ago

Empty means default.

alexbk664 years ago

I did set units, but in browser was getting empty. But after setting other user Preferences (i.e. Map Layer) - the units now appear in Attributes:

{"id":1520,"attributes":{"distanceUnit":"km","speedUnit":"kmh","volumeUnit":"ltr"}
alexbk664 years ago

But via API I still get 404 for session

alexbk664 years ago

Do I actually need to create a new session in API first?

alexbk664 years ago

Yeah, I create a session and it returns attributes.
Thank you Anton.

PS. Probably there's a bug - if you create a new user and set user attributes - the attributes are not reported via API - unless you set any other user Preferences

Anton Tananaev4 years ago

Feel free to create a ticket on GitHub for the bug.

alexbk664 years ago
alexbk664 years ago

Anton,

So I'm reading the units in the user attributes (i.e. km) - but it looks like all distance values from API are in "m"?
So how do I know what are the actual units in API for Distance, TotalDistance, Altitude, Accuracy, Speed?