Ticker
Real-time streaming day OHLCV and last trade data
Last updated
const WebSocket = require('ws')
const ws = new WebSocket('wss://ws.sfox.com/ws')
ws.on('open', function() {
const authMessage = {
type: 'authenticate',
apiKey: '<ENTERPRISE_API_KEY>',
enterprise: 'true'
}
ws.send(JSON.stringify(authMessage))
})
// After successful authentication, subscribe to ticker feed
const subscribeMsg = {
type: 'subscribe',
feeds: ['ticker.sfox.btcusd', 'ticker.sfox.ethusd']
}
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": "authenticate",
"apiKey": "<ENTERPRISE_API_KEY>",
"enterprise": "true"
}))
# After successful authentication message, subscribe to the trades feed
await ws.send(json.dumps({
"type": "subscribe",
"feeds": ["ticker.sfox.btcusd"]
}))
async for msg in ws:
print(msg)
asyncio.run(main("wss://ws.sfox.com/ws")){
"sequence": 4,
"recipient": "ticker.sfox.btcusd",
"timestamp": 1649901842979345289,
"payload": {
"amount": 0.00005737,
"exchange": "coinbase",
"high": 41512.43,
"last": 41420.58,
"low": 41058.82,
"open": 41141.31,
"pair": "btcusd",
"route": "Smart",
"source": "ticker-info",
"timestamp": "2022-04-14T02:04:02.481Z",
"volume": 1387.77211046,
"vwap": 41283.96339697249
}
}