Websocket
In addition to the REST API, we provide an access to a WebSocket endpoint for live updates. Endpoint for the WebSocket connection:
- Name
/api/socket- Type
- websocket
- Description
Each message in the WebSocket stream uses the same universal JSON format:
{
"devices": [...],
"positions": [...],
"events": [...]
}
Each array contains standard JSON objects.
- Name
Device- Type
- schema
- Description
- Name
Position- Type
- schema
- Description
- Name
Event- Type
- schema
- Description
If a message does not contain any objects of a certain type, the key would not be included in the JSON structure. In most cases a message contain a single type of objects.
Security
Session cookie is the only authorization option for the WebSocket connection.
All data is transmitted over WSS, providing encryption in transit to protect against eavesdropping and man-in-the-middle attacks.
A strong authentication mechanism is implemented, utilizing API keys to ensure that only authorized users can establish a connection. Only messages intended for the user are streamed, ensuring that users receive relevant information while maintaining privacy and security.
These features collectively enhance the security of our WebSocket implementation, safeguarding user data and maintaining system integrity.
Consuming websocket
To consume the WebSocket stream, you need to send a connection request to the /api/socket endpoint.
Request
curl -X GET "wss://gw.onemap8.com/api/socket" \
-H "Authorization: Basic {your_access_token}" \
-H "Content-Type: application/json"
In the example above, a websocket connection was established, error management was added and a message was sent to the server.