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.
constWebSocket=require('ws');constws=newWebSocket('wss://ws.sfox.com/ws');// don't forget to subscribe (see below)ws.on('message',function(data) {// Do something with dataconsole.log(data);});
import asyncioimport websocketsasyncdefmain(uri):asyncwith websockets.connect(uri)as ws:# don't forget to subscribe (see below)asyncfor msg in ws:print(msg)asyncio.run(main("wss://ws.sfox.com/ws"))