Balances
The balances feed tracks account balance updates across all of your users' accounts.
Subscription Instructions
private.enterprise.users.balances
user_id
Unique shared ID you generated for the End User account
currency
The currency
balance
Total balance of this currency in your account across all wallets outlined below
available
Portion of the balance that is available for trading or withdrawals
held
Potion of the balance that is currently on hold and unavailable for trading or withdrawals e.g. an ACH deposit that has yet to settle
trading_wallet
Amount of the currency in your trading wallet
borrow_wallet
Amount of the currency , represented as the borrow wallet balance
collateral_wallet
Amount of the current being held as collateral in your collateral wallet
lending_wallet
Amount of the currency in your lending wallet
Example Code
const WebSocket = require('ws')
const ws = new WebSocket('wss://ws.sfox.com/ws')
ws.on('open', function() {
const authMessage = {
type: 'authenticate',
apiKey: `${process.env.ENTERPRISE_API_KEY}`,
enterprise: 'true'
}
ws.send(JSON.stringify(authMessage))
})
// After successful authentication, subscribe to user balances feed
const subscribeMsg = {
type: 'subscribe',
feeds: ['private.enterprise.users.balances']
}
ws.send(JSON.stringify(subscribeMsg))import asyncio
import json
import websockets
import os
async def main(uri):
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"type": "authenticate",
"apiKey": f"{os.environ['ENTERPRISE_API_KEY']}",
"enterprise": "true"
}))
# After successful authentication message, subscribe to the user balances feed
await ws.send(json.dumps({
"type": "subscribe",
"feeds": ["private.enterprise.users.balances"]
}))
async for msg in ws:
print(msg)
asyncio.run(main("wss://ws.sfox.com/ws")){
"sequence": 22,
"recipient": "private.enterprise.users.balances",
"timestamp": 1710367225302228171,
"payload": {
"user_id": "test3", //Unique shared ID you generated for the End User account
"updates": [
{
"currency": "btc",
"balance": "9.99850081", //Total balance in the account
"available": "9.99850081", //Balance available for trading / withdrawals
"held": "0", //Funds locked in the account
"trading_wallet": "9.99850081", //Balance in the trading wallet of the account
"collateral_wallet": "0", //Balance in the collateral wallet of the account
"borrow_wallet": "0", //Balance borrowed by the account
"lending_wallet": "0", //Balance lent by the account
"staking_wallet": "0" //Balance staked by the account
},
{
"currency": "eth",
"balance": "0.01826367",
"available": "0.01826367",
"held": "0",
"trading_wallet": "0.01826367",
"collateral_wallet": "0",
"borrow_wallet": "0",
"lending_wallet": "0",
"staking_wallet": "0"
},
{
"currency": "usd",
"balance": "100035.33054742",
"available": "100035.33054742",
"held": "0",
"trading_wallet": "100035.33054742",
"collateral_wallet": "0",
"borrow_wallet": "0",
"lending_wallet": "0",
"staking_wallet": "0"
}
]
}
}Last updated