Home Platform Algorithms Charts Pricing Documentation Register Account

Cloud9Trader API

WebSocket API

The WebSocket API can be connected to with native WebSocket over TCP. If you are developing in JavaScript, the WebSocket API Client Library will be the quickest way for you to get started.

The API can be connected to publicly or authenticated. The public socket provides real time market data - pricing, tickers, order books and the public trades feed. To initiate a public socket, connect to wss://sockets.cloud9trader.com/. TODO, for example in NodeJS:

const WebSocket = require("ws");

const socket = new WebSocket("wss://sockets.cloud9trader.com/");

this.socket.addEventListener("open", () => {
    console.info("Cloud9Trader socket open");
});

this.socket.addEventListener("close", () => {
    console.info("Cloud9Trader socket closed");
});

this.socket.addEventListener("message", (event) => {
    try {
        let [topic, ...args] = JSON.parse(event.data);
        console.info("Cloud9Trader socket received", topic, ...args);
    } catch (error) {
        return console.error("Cloud9Trader socket could not parse incoming message");
    }
});

this.socket.send(JSON.stringify(["subscribe", "orders"]));

You'll notice messages are transmitted as stringified arrays of arguments. More information on that on the Message Structure page.

To submit orders and stream your balances, positions and other private data, you'll need an authenticated socket. Instructions are over on the WebSocket Authentication page.

Was this page useful? If you find any errors or have any questions please get in touch at support@cloud9trader.com.