Skip to main content

Documentation Index

Fetch the complete documentation index at: https://whitebit-mintlify-seo-descriptions-1777248505.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Monitor account state across Main, Trade, and Collateral balances using REST endpoints and WebSocket streams. This guide covers balance queries, deposit/withdrawal tracking, order activity monitoring, and the decision framework for choosing between REST polling and WebSocket subscriptions. Applicable to any integration that needs real-time or periodic account state awareness. Payment processing integrations (deposit/withdrawal monitoring): focus on the balance monitoring and deposit/withdrawal tracking sections — Main balance does not support WebSocket streaming, so webhooks and REST polling are the primary mechanisms. Trading integrations (bots, dashboards): focus on balance monitoring and order activity monitoring via WebSocket for real-time state.

Balance monitoring

WhiteBIT separates funds into three account types. Each has a dedicated balance endpoint:
Account typeEndpointDoc page
MainPOST /api/v4/main-account/balanceMain Balance
Trade (Spot)POST /api/v4/trade-account/balanceTrading Balance
CollateralPOST /api/v4/collateral-account/balanceCollateral Balance
For an explanation of account types and how funds move between them, see Balances & Transfers.

Fetch Trade balance

# See /api-reference/authentication for signing details.
curl -X POST https://whitebit.com/api/v4/trade-account/balance \
  -H "Content-Type: application/json" \
  -H "X-TXC-APIKEY: YOUR_API_KEY" \
  -H "X-TXC-PAYLOAD: BASE64_PAYLOAD" \
  -H "X-TXC-SIGNATURE: HMAC_SIGNATURE" \
  -d '{"request":"/api/v4/trade-account/balance","nonce":"1700000000000"}'
For Go and PHP examples, see SDKs. Response fields:
  • available — funds ready for trading or withdrawal
  • freeze — funds locked in open orders or pending operations

Real-time balance via WebSocket

REST polling provides point-in-time snapshots. For instant balance change notifications, subscribe to WebSocket account streams:
ChannelSubscribe methodUse case
Balance SpotbalanceSpot_subscribeSpot (Trade) balance changes
Balance MarginbalanceMargin_subscribeCollateral balance changes (Margin + Futures)
Main balance does not have a WebSocket subscription channel. Monitor Main balance changes — including deposit arrivals — via webhooks for real-time notifications or REST polling of POST /api/v4/main-account/history as a fallback.

Subscribe to balance updates

The following example assumes an authenticated WebSocket session. See WebSocket Quickstart — Authenticate for private channels for the full authentication flow. Without authentication, the subscription request is rejected.
import json, websockets, asyncio

async def monitor_balance():
    async with websockets.connect("wss://api.whitebit.com/ws") as ws:
        # Authenticate first — see WebSocket Quickstart Step 4 for the full flow.
        # Without auth, balanceSpot_subscribe silently fails.

        # Subscribe to spot balance changes.
        # params: [] subscribes to all assets.
        # Pass specific tickers (e.g., ["USDT", "BTC"]) to filter updates.
        await ws.send(json.dumps({
            "id": 1,
            "method": "balanceSpot_subscribe",
            "params": []
        }))

        async for message in ws:
            data = json.loads(message)
            # Subscription confirmation has a "result" key.
            # Balance updates have a "method" key set to "balanceSpot_update".
            if "method" in data and data["method"] == "balanceSpot_update":
                for asset, info in data["params"].items():
                    print(f"Balance change: {asset} available={info['available']} freeze={info['freeze']}")

asyncio.run(monitor_balance())

Deposit and withdrawal tracking

REST polling

Query deposit and withdrawal history using the main account history endpoint: Endpoint: POST /api/v4/main-account/history
curl -X POST https://whitebit.com/api/v4/main-account/history \
  -H "Content-Type: application/json" \
  -H "X-TXC-APIKEY: YOUR_API_KEY" \
  -H "X-TXC-PAYLOAD: BASE64_PAYLOAD" \
  -H "X-TXC-SIGNATURE: HMAC_SIGNATURE" \
  -d '{"transactionMethod":1,"request":"/api/v4/main-account/history","nonce":"1700000000000"}'

Webhook-based monitoring

For real-time deposit and withdrawal notifications, configure webhooks. Webhook delivery includes up to 5 retries at 10-minute intervals (50-minute coverage window). Recommended reconciliation approach:
  • Primary: Webhooks — process events as they arrive for near-instant updates
  • Fallback: REST polling — periodically query the history endpoint to catch any events missed during webhook downtime or after the 50-minute retry window expires
See Webhooks for setup, signature verification, and event types. For the full deposit/withdrawal lifecycle including status state machines and fee calculation, see Payment Integration.

Order activity monitoring

Open orders

Query active orders across all markets or filter by a specific market: Endpoint: POST /api/v4/orders
curl -X POST https://whitebit.com/api/v4/orders \
  -H "Content-Type: application/json" \
  -H "X-TXC-APIKEY: YOUR_API_KEY" \
  -H "X-TXC-PAYLOAD: BASE64_PAYLOAD" \
  -H "X-TXC-SIGNATURE: HMAC_SIGNATURE" \
  -d '{"market":"BTC_USDT","request":"/api/v4/orders","nonce":"1700000000000"}'

Executed orders

Query trade history for filled and canceled orders: Endpoint: POST /api/v4/trade-account/order/history
curl -X POST https://whitebit.com/api/v4/trade-account/order/history \
  -H "Content-Type: application/json" \
  -H "X-TXC-APIKEY: YOUR_API_KEY" \
  -H "X-TXC-PAYLOAD: BASE64_PAYLOAD" \
  -H "X-TXC-SIGNATURE: HMAC_SIGNATURE" \
  -d '{"market":"BTC_USDT","request":"/api/v4/trade-account/order/history","nonce":"1700000000000"}'

Real-time order updates via WebSocket

For instant order state change notifications, subscribe to account streams:
ChannelSubscribe methodEvents
Orders PendingordersPending_subscribeOrder placed, partially filled, canceled
Dealsdeals_subscribeTrade executions (fills)
For final order state with aggregate data (fully filled or canceled), see also Orders Executed.
# Subscribe to order updates and trade fills
await ws.send(json.dumps({
    "id": 2,
    "method": "ordersPending_subscribe",
    "params": ["BTC_USDT"]
}))
await ws.send(json.dumps({
    "id": 3,
    "method": "deals_subscribe",
    "params": [["BTC_USDT"]]
}))

Polling vs WebSocket decision matrix

Use caseRecommended approachReason
Balance snapshotRESTOne-time check, no persistent connection needed
Live balance changesWebSocketInstant notification on every change
Deposit/withdrawal statusWebhook + REST fallbackReliability — webhooks for speed, REST for reconciliation
Open order monitoringWebSocketReal-time state changes (fills, cancellations)
Historical tradesRESTPaginated query over a time range
General guidance: Use REST for on-demand queries and historical data. Use WebSocket for any data that changes frequently and requires immediate reaction. Combine both: WebSocket for primary real-time flow, REST for startup state hydration and periodic reconciliation. When using REST polling, align the interval with the use case and the endpoint rate budget. See Rate Limits & Error Codes for per-scope request limits.
Use caseEndpointSuggested interval
Balance dashboardPOST /api/v4/trade-account/balance5–30 seconds
Deposit detection (fallback)POST /api/v4/main-account/history5 minutes
Order history reconciliationPOST /api/v4/trade-account/order/history30–60 seconds

What’s Next

Payment Integration

Full deposit/withdrawal lifecycle, fee calculation, and reconciliation.

WebSocket Quickstart

Connection setup, authentication, and real-time data streaming.

Trading Bot

End-to-end automated trading with order management and error handling.