api/socket

pipe91913 days ago

Hello everyone. Here’s the context: I want to use the Traccar socket, but my goal is to leverage it in order to retrieve all positions, devices, or events across my entire platform using a single user.
is that possible and how?

ValeT13 days ago

Hi pipe919,

Yes, what you're describing is absolutely possible and is the standard way to get a global, real-time view of your entire platform.

The key is to use a user account that has the necessary permissions. You need to connect to the WebSocket using the session of either an Administrator account or a Manager account that has access to all the devices.

The general workflow is quite simple:

Authenticate First: Use the REST API to log in with your admin/manager credentials by making a POST request to /api/session.

Get the Session Cookie: A successful login will return a JSESSIONID cookie. This cookie proves you have an active admin session.

Connect to the WebSocket: Establish your WebSocket connection to /api/socket, making sure to include the JSESSIONID cookie from the previous step in your connection headers.

Once connected, the Traccar server will recognize the admin session and will automatically start pushing all platform-wide data (positions, devices, events) to your client in real-time. This is the correct approach for building any kind of central monitoring dashboard or application.

pipe91912 days ago

Thanks for your reply, it turns out I was forgetting to insert the data into tc_user_device