Get Wallet Balance
Obtain wallet balance, query asset information of each currency. By default, currency information with assets or liabilities of 0 is not returned.
info
Under the new logic of UTA manual borrow, spotBorrow field corresponding to spot liabilities is detailed in the announcement.
Old walletBalance = New walletBalance - spotBorrow
HTTP Request
GET /v5/account/wallet-balance
Request Parameters
| Parameter | Required | Type | Comments |
|---|---|---|---|
| accountType | true | string | Account type UNIFIED. To get Funding wallet balance, please go to this endpoint |
| coin | false | string | Coin name, uppercase only
|
Response Parameters
| Parameter | Type | Comments |
|---|---|---|
| list | array | Object |
| > accountType | string | Account type |
| > accountIMRate | string | Account IM rate |
| > accountMMRate | string | Account MM rate |
| > totalEquity | string | Account total equity (USD): ∑Asset Equity By USD value of each asset |
| > totalWalletBalance | string | Account wallet balance (USD): ∑Asset Wallet Balance By USD value of each asset |
| > totalMarginBalance | string | Account margin balance (USD): totalWalletBalance + totalPerpUPL |
| > totalAvailableBalance | string | Account available balance (USD),
|
| > totalPerpUPL | string | Account Perps and Futures unrealised p&l (USD): ∑Each Perp and USDC Futures upl by base coin |
| > totalInitialMargin | string | Account initial margin (USD): ∑Asset Total Initial Margin Base Coin |
| > totalMaintenanceMargin | string | Account maintenance margin (USD): ∑ Asset Total Maintenance Margin Base Coin |
| > accountIMRateByMp | string | You can ignore this field, and refer to accountIMRate, which has the same calculation |
| > accountMMRateByMp | string | You can ignore this field, and refer to accountMMRate, which has the same calculation |
| > totalInitialMarginByMp | string | You can ignore this field, and refer to totalInitialMargin, which has the same calculation |
| > totalMaintenanceMarginByMp | string | You can ignore this field, and refer to totalMaintenanceMargin, which has the same calculation |
| > accountLTV | string | Deprecated field |
| > coin | array | Object |
| >> coin | string | Coin name, such as BTC, ETH, USDT, USDC |
| >> equity | string | Equity of coin. Asset Equity = Asset Wallet Balance + Asset Perp UPL + Asset Future UPL + Asset Option Value = walletBalance - spotBorrow + unrealisedPnl + Asset Option Value |
| >> usdValue | string | USD value of coin |
| >> walletBalance | string | Wallet balance of coin |
| >> locked | string | Locked balance due to the Spot open order |
| >> spotHedgingQty | string | The spot asset qty that is used to hedge in the portfolio margin, truncate to 8 decimals and "0" by default |
| >> borrowAmount | string | Borrow amount of current coin = spot liabilities + derivatives liabilities |
| >> accruedInterest | string | Accrued interest |
| >> totalOrderIM | string | Pre-occupied margin for order. For portfolio margin mode, it returns "" |
| >> totalPositionIM | string | Sum of initial margin of all positions + Pre-occupied liquidation fee. For portfolio margin mode, it returns "" |
| >> totalPositionMM | string | Sum of maintenance margin for all positions. For portfolio margin mode, it returns "" |
| >> unrealisedPnl | string | Unrealised P&L |
| >> cumRealisedPnl | string | Cumulative Realised P&L |
| >> bonus | string | Bonus |
| >> marginCollateral | boolean | Whether it can be used as a margin collateral currency (platform), true: YES, false: NO |
| >> collateralSwitch | boolean | Whether the collateral is turned on by user (user), true: ON, false: OFF |
| >> spotBorrow | string | Borrow amount by spot margin trade and manual borrow amount (does not include borrow amount by spot margin active order). spotBorrow field corresponding to spot liabilities is detailed in the announcement. |
| >> free | string | Deprecated since there is no Spot wallet any more |
| >> availableToWithdraw | string | Deprecated for accountType=UNIFIED from 9 Jan, 2025
|
| >> availableToBorrow | string | Deprecated field, always return "". Please refer to availableToBorrow in the Get Collateral Info |
Request Example
- HTTP
- Python
- Node.js
GET /v5/account/wallet-balance?accountType=UNIFIED&coin=BTC HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1672125440406
X-BAPI-RECV-WINDOW: 5000
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
print(session.get_wallet_balance(
accountType="UNIFIED",
coin="BTC",
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'xxxxxxxxxxxxxxxxxx',
secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
});
client
.getWalletBalance({
accountType: 'UNIFIED',
coin: 'BTC',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"totalEquity": "3.31216591",
"accountIMRate": "0",
"accountIMRateByMp": "0",
"totalMarginBalance": "3.00326056",
"totalInitialMargin": "0",
"totalInitialMarginByMp": "0",
"accountType": "UNIFIED",
"totalAvailableBalance": "3.00326056",
"accountMMRate": "0",
"accountMMRateByMp": "0",
"totalPerpUPL": "0",
"totalWalletBalance": "3.00326056",
"accountLTV": "0",
"totalMaintenanceMargin": "0",
"totalMaintenanceMarginByMp": "0",
"coin": [
{
"availableToBorrow": "3",
"bonus": "0",
"accruedInterest": "0",
"availableToWithdraw": "0",
"totalOrderIM": "0",
"equity": "0",
"totalPositionMM": "0",
"usdValue": "0",
"spotHedgingQty": "0.01592413",
"unrealisedPnl": "0",
"collateralSwitch": true,
"borrowAmount": "0.0",
"totalPositionIM": "0",
"walletBalance": "0",
"cumRealisedPnl": "0",
"locked": "0",
"marginCollateral": true,
"coin": "BTC",
"spotBorrow": "0"
}
]
}
]
},
"retExtInfo": {},
"time": 1690872862481
}