Real-time tick data feed of all trades executed on SFOX’s supported liquidity sources
Subscription Instructions
Example Code & Trades Message
const WebSocket = require('ws')
const ws = new WebSocket('wss://ws.sfox.com/ws')
ws.on('message', function(data) {
console.log(data);
});
ws.on('open', function() {
const subscribeMsg = {
type: 'subscribe',
feeds: ['trades.sfox.btcusd']
}
ws.send(JSON.stringify(subscribeMsg));
});
import asyncio
import json
import websockets
async def main(uri):
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"type": "subscribe",
"feeds": [
"trades.sfox.btcusd",
],
}))
async for msg in ws:
print(msg)
asyncio.run(main("wss://ws.sfox.com/ws"))
{
"sequence": 24,
"recipient": "trades.sfox.btcusd",
"timestamp": 1649901441593380244,
"payload": {
"id": "1062696823",
"quantity": "0.005",
"price": "41492",
"exchange": "bitfinex",
"exchange_id": 2,
"side": "buy",
"pair": "btcusd",
"pair_id": 1,
"timestamp": "2022-04-14T01:57:21.521999872Z",
"timeStamp": "2022-04-14T01:57:21.521",
"buyOrderId": "",
"sellOrderId": "",
"is_decimal": true
}
}