๐Ÿ“– Tronsell Wiki

Account Balance API Guide: Check Crypto Balances Programmatically

Complete guide to Account Balance APIs on cryptocurrency exchanges โ€” learn how to check spot, futures, and earn balances programmatically, understand balance types, and build reliable balance monitoring systems.

๐Ÿ’ฐ Balance API at a Glance
What It Does Retrieve spot, futures, and earn balances
Balance Types Available, Locked, Total
Authentication API key with Read permissions
Key Use Before placing orders, monitoring
Rate Limits Lower than public endpoints
Best Practice Cache balances locally

๐Ÿ’ฐ What is an Account Balance API?

An Account Balance API is a programmatic interface that allows you to retrieve your cryptocurrency balances from an exchange. It provides access to:

  • Spot balances โ€” funds in your spot wallet.
  • Futures balances โ€” funds in your futures account.
  • Earn balances โ€” funds in staking, savings, or other earn products.
  • Balance types โ€” available (free to use), locked (in orders or staking), and total (available + locked).

Account Balance APIs are authenticated endpoints โ€” they require an API key with Read permissions. They are essential for trading bots, portfolio trackers, and any application that needs to know how much capital is available.

๐Ÿ’ก Why Balance APIs are Critical
  • Before placing orders: Ensure you have sufficient funds.
  • Risk management: Monitor portfolio exposure.
  • Position sizing: Calculate position sizes based on available capital.
  • Reconciliation: Verify balances match your records.
5+
Balance types (spot, futures, earn, etc.)
100+
Assets per exchange
1s
Real-time balance updates
Read
Required permission

๐Ÿ“Š Understanding Balance Types

When you retrieve your balance, the API returns different types of balances. Understanding them is crucial for accurate position management.

โœ…
Available Balance

The amount you can use for trading, withdrawals, or transfers. This is the balance you should check before placing orders.

๐Ÿ”’
Locked Balance

Funds that are unavailable because they're in open orders, staking, or other active positions. You cannot use these funds until they are unlocked.

๐Ÿ“Š
Total Balance

The sum of available and locked balances. This is your total position in the asset.

๐Ÿ“ˆ
Equity/Cross Balance

For futures accounts, this includes unrealized P&L. It represents the total value of your account if all positions were closed at current prices.

๐Ÿ“Œ Balance Example

If you have 1.0 BTC in your spot wallet, with 0.2 BTC locked in an open order, then:
Available = 0.8 BTC, Locked = 0.2 BTC, Total = 1.0 BTC.

๐Ÿ“‹ Key Account Balance Endpoints

Here are the most important balance endpoints across major exchanges. Note that endpoints differ by exchange.

Endpoint Description Method Requires Auth?
/api/v3/account Get all spot account balances GET Yes (Read)
/fapi/v1/account Get futures account balances GET Yes (Read)
/api/v3/account/asset Get balance for a specific asset GET Yes (Read)
/api/v5/asset/balances OKX โ€” Get spot account balances GET Yes (Read)
/api/v5/asset/funding-balance OKX โ€” Get funding account balances GET Yes (Read)
/v5/account/wallet-balance Bybit โ€” Get wallet balances GET Yes (Read)
๐Ÿ’ก Note

Endpoint URLs vary by exchange. Binance uses /api/v3/ for spot and /fapi/v1/ for futures. OKX uses /api/v5/. Bybit uses /v5/. Always refer to the exchange's official API documentation.

๐Ÿ’Ž Checking Spot Balances

Spot balances represent the funds in your main trading account. Here's how to retrieve them.

Get All Spot Balances

GET /api/v3/account
Returns all assets with available, locked, and total balances

Get a Specific Asset Balance

GET /api/v3/account/asset
Parameters: asset=BTC (returns balance for BTC only)

The account endpoint returns a list of balances. Each balance typically includes:

  • asset: The asset symbol (e.g., BTC, ETH, USDT).
  • free: Available balance (can be used for trading or withdrawal).
  • locked: Locked balance (in open orders, staking, etc.).
  • total: free + locked.
๐Ÿ’ก Pro Tip

Before placing an order, always check your available balance to ensure you have sufficient funds. Consider reserving a small buffer for fees, especially for market orders where the exact cost may vary.

๐Ÿ“ˆ Checking Futures Balances

Futures balances are separate from spot balances and include margin, unrealized P&L, and available funds for leveraged trading.

Get Futures Account Info

GET /fapi/v1/account
Returns futures account balance, margin, and position info

The futures account endpoint returns:

  • totalCrossMargin: Total margin in cross margin mode.
  • totalIsolatedMargin: Total margin in isolated margin mode.
  • totalUnrealizedProfit: Unrealized P&L across all positions.
  • totalAvailableBalance: Available funds for trading.
  • assets: List of assets with margin balances.
โš ๏ธ Futures Balance Warning

Futures balances include unrealized P&L. This means the balance can change rapidly with market movements. Always use the available balance (not total balance) when determining how much margin you can use.

๐Ÿฆ Checking Earn Account Balances

Earn balances represent funds in staking, savings, or other earn products. These funds are typically locked and not available for trading.

Get Earn Balances

GET /api/v3/account (or exchange-specific earn endpoint)
Earn balances are often returned alongside spot balances, with a separate designation

Some exchanges have separate endpoints for earn balances. Check the exchange's documentation for specific earn balance endpoints.

๐Ÿ’ก Pro Tip

When calculating your total net worth on an exchange, sum up spot, futures, and earn balances. However, for trading decisions, only use the available balance in your spot account.

๐Ÿ† Best Practices for Balance APIs

Follow these best practices when working with Account Balance APIs.

  • 1
    Cache balances locally

    Balances don't change every millisecond. Cache the response for 1-5 seconds to reduce API calls and rate limit usage.

  • 2
    Check available balance before orders

    Always verify you have sufficient available balance before placing an order to avoid "insufficient balance" errors.

  • 3
    Monitor locked balances

    If your locked balance is high, you may have open orders or positions that are consuming funds. Monitor this to understand your capital usage.

  • 4
    Use WebSocket for real-time updates

    Some exchanges offer WebSocket streams for account balance updates, providing real-time balance changes without polling.

  • 5
    Handle authentication errors

    If your API key expires or permissions change, your balance requests will fail. Implement proper error handling and monitoring.

  • 6
    Respect rate limits

    Balance endpoints are authenticated and typically have lower rate limits than public endpoints. Cache responses to minimize requests.

โ“ Frequently Asked Questions About Account Balance APIs

What is an Account Balance API?

An Account Balance API is a programmatic interface that allows you to retrieve your cryptocurrency balances from an exchange. It provides access to spot balances, futures balances, earn account balances, and detailed information about available, locked, and total balances for each asset.

What types of balances can I get from the API?

You can get: available balance (free to use), locked balance (in open orders or staking), total balance (available + locked), and in some cases, balances for different account types like spot, futures, earn, and margin accounts.

Do I need an API key to check my balance?

Yes, Account Balance APIs are authenticated endpoints and require an API key with 'Read' permissions. This ensures that only you can access your account information.

How often should I check my balance?

The frequency depends on your needs. For trading bots, checking before placing orders is essential. For monitoring, every 1-5 minutes is typical. Be mindful of rate limits โ€” don't poll too frequently.

What is the difference between available and total balance?

Available balance is the amount you can use for trading, withdrawals, or transfers. Total balance includes both available and locked funds. Locked funds are those tied up in open orders, staking, or other active positions.

Can I get balance information via WebSocket?

Some exchanges offer WebSocket streams for account balance updates. This provides real-time balance changes without polling. Check the exchange's WebSocket documentation for available streams.

What permissions do I need for balance APIs?

You need Read permission for balance APIs. This is the minimum permission required to view your account information. Never enable trade or withdrawal permissions on keys used only for balance checking.

What are the rate limits for balance APIs?

Rate limits vary by exchange and are typically lower for authenticated endpoints than public ones. Binance has 1200 weight/min, OKX has 50 requests/sec, Bybit has 50 requests/sec. Balance requests consume weight/requests, so cache responses to stay within limits.

๐Ÿ’ฐ Start Monitoring Your Balances

Build reliable balance monitoring systems with Account Balance APIs. Check spot, futures, and earn balances programmatically and make informed trading decisions.