UNI-Cloud API 1.1

Homepage Integration

Overviewchevron_right
Endpointschevron_right

API Changelog

Please beware that the documentation is still in Alpha!

linkReal-Time Data Streaming

To access real-time updates, you must connect to the websocket endpoint provided by the API; which are highlighted by the Real-Time label, or the HTTP-UPGRADE tag near a code example. The API provides these specific websocket endpoints for various data streams, tailored to meet specific business requirements or use cases. For example, you may connect to a websocket endpoint to receive real-time UNI positions, or receive real-time UNI states.

To take advantage of websocket support, you must implement it on both your client and server-side. On the client-side, this typically involves using a websocket library or API. On the server-side, the API requires you to implement websocket handling and processing, using a websocket framework or library.

UPGRADE
1link// Create a new websocket connection

2linkconst socket = new WebSocket("wss://hubs.marxact.com/" + <~endpoint~~~~~~~~>~);

3link

4link// Listen for the "open" event, which is triggered when the connection is established

5linksocket.addEventListener("open", (event: MessageEvent) => {

6link console.log("WebSocket connection established");

7link});

8link

9link// Listen for incoming messages

10linksocket.addEventListener("message", (event: MessageEvent) => {

11link const data: <~endpoint~~~~~~~~>~Model = event.data;

12link console.log("Received model:", data);

13link});

14link

15link// Listen for the "close" event, which is triggered when the connection is closed

16linksocket.addEventListener("close", (event: MessageEvent) => {

17link console.log("WebSocket connection closed");

18link});

In this example, a new websocket connection is established by creating a new WebSocket object and passing in the websocket URL. The open, message, and close events are then listened for, allowing you to handle the different states of the connection and receive incoming messages.

Other websocket libraries or APIs may have slightly different APIs, but the basic process of connecting to a websocket URL and receiving incoming messages is similar across all implementations.