sFOX API
Sign InOpen Account
Connect API
Connect API
  • Introduction
    • Welcome
    • Getting Started
    • Resources
      • Terminology
      • Systems & Operations
      • Integration Options
    • Guides
      • End User Onboarding & KYC
        • Individuals
        • Businesses
        • Enhanced Due Diligence
  • REST API
    • REST Endpoints
    • Authentication
    • End Users
      • Create End User Account
      • Request Verification Code
      • Confirm Verification Code
      • Create User Auth Token(s)
      • Get End User(s)
      • Get EDD Requests
      • Get EDD Prompts
      • Create EDD Responses
        • Uploading Files as Responses
      • Submit Documents
      • Deactivate User
    • Payments
      • Create Bank Account (Plaid)
      • Create Bank Account
      • Get Bank Account
      • Get Plaid Processors
      • Amend Plaid Processors
      • Verify Bank Account
      • Delete Bank Account
      • Get Wire Instructions
      • Get ACH Agreement Status
      • Request ACH Onboarding
      • Get ACH Deposit Limit
    • Withdrawals
      • Confirm Withdrawal
      • Resend Confirmation Code
      • Cancel Withdrawal
    • Transfers
      • Create Transfer
      • Confirm Transfer
      • Resend Confirmation Code
      • Cancel Transfer
      • Get Transfer Permissions
      • Get Transfer History
    • Monetization
      • Create Setting
      • Update Setting
      • Delete Setting
      • Get Settings
      • Get Permissions
      • Get Monetization History
  • WebSocket API
    • Connecting
    • Authentication
    • Subscribing & Unsubscribing
    • Message Format
    • End Users
      • Onboarding
      • Balances
      • Orders
      • Trades
    • Market Data
      • Order Book
      • Trades
      • Ticker
  • Single Sign-On
    • Overview
      • IdP Initiated SSO
    • IdP Data
    • SAML Response Data
  • Errors
    • Error Codes
Powered by GitBook
On this page
  • Subscription Instructions
  • Example Code
  1. WebSocket API
  2. End Users

Balances

The balances feed tracks account balance updates across all of your users' accounts.

A balance update from this feed will include the user_id of the user to use to identify which user's account the update is for as well as this user's current balances across all currencies in the account.

Subscription Instructions

Feed Name

private.enterprise.users.balances

Key
Description

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"
            }
        ]
    }
}

PreviousOnboardingNextOrders

Last updated 11 months ago