For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connecting

Connecting to the sFOX WebSocket API gives you access to real-time market and/or account data.

WebSocket API URLs

Use the following URLs to connect to sFOX WebSocket APIs.

Environment
Endpoint

Production

wss://ws.sfox.com/ws

Sandbox

wss://ws.staging.sfox.com/ws Contact support to access the sandbox environment.

Example Code

Examples of establishing a WebSocket connection are shown below.

const WebSocket = require('ws');

const ws = new WebSocket('wss://ws.sfox.com/ws');

// don't forget to subscribe (see below)
ws.on('message', function(data) {
    // Do something with data
    console.log(data);
});
import asyncio

import websockets

async def main(uri):
    async with websockets.connect(uri) as ws:
        # don't forget to subscribe (see below)
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))

Last updated