Connecting
Connecting to the WebSocket API
Connecting to the sFOX websocket feed gives you access to real-time market data from all supported exchanges.
Environment | Endpoint |
---|---|
Production | wss://ws.sfox.com/ws |
Sandbox |
NodeJS
Python
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 modified 22d ago