or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

account.mdconvert-api.mddepth-cache.mdfutures.mdindex.mdmargin.mdmarket-data.mdrest-clients.mdstaking-mining.mdtrading.mdwebsockets.md

account.mddocs/

0

# Account Management

1

2

Account information, balance management, trade history, and API permissions. Includes wallet operations, asset transfers, and comprehensive account status monitoring.

3

4

## Capabilities

5

6

### Account Information

7

8

Get comprehensive account details including balances, trading status, and permissions.

9

10

```python { .api }

11

def get_account(self, **params): ...

12

def get_asset_balance(self, asset=None, **params): ...

13

def get_account_status(self, version=1, **params): ...

14

def get_account_api_trading_status(self, **params): ...

15

def get_account_api_permissions(self, **params): ...

16

```

17

18

#### Usage Examples

19

20

```python

21

# Get complete account information

22

account = client.get_account()

23

24

# Extract balances with non-zero amounts

25

balances = {b['asset']: {'free': b['free'], 'locked': b['locked']}

26

for b in account['balances'] if float(b['free']) > 0 or float(b['locked']) > 0}

27

28

print(f"Account type: {account['accountType']}")

29

print(f"Can trade: {account['canTrade']}")

30

print(f"Can withdraw: {account['canWithdraw']}")

31

print(f"Can deposit: {account['canDeposit']}")

32

print(f"Balances: {balances}")

33

34

# Get specific asset balance

35

btc_balance = client.get_asset_balance(asset='BTC')

36

if btc_balance:

37

print(f"BTC Balance - Free: {btc_balance['free']}, Locked: {btc_balance['locked']}")

38

39

# Check account status

40

status = client.get_account_status()

41

print(f"Account status: {status['data']}") # "Normal" or other status

42

43

# Get API trading status

44

api_status = client.get_account_api_trading_status()

45

print(f"API trading enabled: {api_status['data']['isLocked'] == False}")

46

47

# Get API permissions

48

permissions = client.get_account_api_permissions()

49

print(f"Permissions: {permissions['data']}")

50

# Shows: ipRestrict, createTime, enableWithdrawals, enableInternalTransfer,

51

# permitsUniversalTransfer, enableVanillaOptions, enableReading,

52

# enableFutures, enableMargin, enableSpotAndMarginTrading

53

```

54

55

### Trading History

56

57

Access trade history and order information.

58

59

```python { .api }

60

def get_my_trades(self, **params): ...

61

def get_all_orders(self, **params): ...

62

def get_open_orders(self, **params): ...

63

```

64

65

#### Usage Examples

66

67

```python

68

# Get recent trades for specific symbol

69

trades = client.get_my_trades(symbol='BTCUSDT', limit=100)

70

71

for trade in trades:

72

print(f"Trade ID: {trade['id']}")

73

print(f"Price: {trade['price']}, Qty: {trade['qty']}")

74

print(f"Commission: {trade['commission']} {trade['commissionAsset']}")

75

print(f"Time: {trade['time']}")

76

print(f"Is buyer: {trade['isBuyer']}, Is maker: {trade['isMaker']}")

77

78

# Get trades within date range

79

import time

80

end_time = int(time.time() * 1000)

81

start_time = end_time - (7 * 24 * 60 * 60 * 1000) # 7 days ago

82

83

recent_trades = client.get_my_trades(

84

symbol='BTCUSDT',

85

startTime=start_time,

86

endTime=end_time

87

)

88

89

# Get all historical orders

90

all_orders = client.get_all_orders(symbol='BTCUSDT', limit=500)

91

92

# Filter by order status

93

filled_orders = [o for o in all_orders if o['status'] == 'FILLED']

94

print(f"Total filled orders: {len(filled_orders)}")

95

```

96

97

### Dust Operations

98

99

Manage small balance amounts (dust) that are too small to trade.

100

101

```python { .api }

102

def get_dust_assets(self, **params): ...

103

def get_dust_log(self, **params): ...

104

def transfer_dust(self, **params): ...

105

```

106

107

#### Usage Examples

108

109

```python

110

# Get dust assets (small balances)

111

dust_assets = client.get_dust_assets()

112

print(f"Dust assets: {dust_assets['details']}")

113

114

# Get dust conversion history

115

dust_log = client.get_dust_log()

116

for entry in dust_log['userAssetDribblets']:

117

print(f"Converted on {entry['operateTime']}: {entry['totalTransferedAmount']} BNB")

118

119

# Convert dust to BNB

120

dust_result = client.transfer_dust(asset=['ADA', 'XRP', 'DOT'])

121

print(f"Dust transfer result: {dust_result}")

122

```

123

124

### Asset Dividends and Distribution

125

126

Track dividend payments and asset distributions.

127

128

```python { .api }

129

def get_asset_dividend_history(self, **params): ...

130

```

131

132

#### Usage Examples

133

134

```python

135

# Get dividend payment history

136

dividends = client.get_asset_dividend_history(limit=100)

137

138

for dividend in dividends['rows']:

139

print(f"Asset: {dividend['asset']}")

140

print(f"Amount: {dividend['amount']}")

141

print(f"Dividend time: {dividend['divTime']}")

142

print(f"Transaction ID: {dividend['tranId']}")

143

```

144

145

### Wallet Operations

146

147

Deposit and withdrawal operations and history.

148

149

```python { .api }

150

def get_deposit_history(self, **params): ...

151

def get_withdraw_history(self, **params): ...

152

def get_deposit_address(self, **params): ...

153

def withdraw(self, **params): ...

154

```

155

156

#### Usage Examples

157

158

```python

159

# Get deposit history

160

deposits = client.get_deposit_history(coin='BTC', limit=100)

161

162

for deposit in deposits:

163

print(f"Amount: {deposit['amount']} {deposit['coin']}")

164

print(f"Status: {deposit['status']}") # 0: pending, 6: credited, 1: success

165

print(f"Network: {deposit['network']}")

166

print(f"TxId: {deposit['txId']}")

167

168

# Get withdrawal history

169

withdrawals = client.get_withdraw_history(coin='BTC', limit=100)

170

171

for withdrawal in withdrawals:

172

print(f"Amount: {withdrawal['amount']} {withdrawal['coin']}")

173

print(f"Status: {withdrawal['status']}")

174

print(f"Network: {withdrawal['network']}")

175

print(f"TxId: {withdrawal['txId']}")

176

177

# Get deposit address

178

deposit_addr = client.get_deposit_address(coin='BTC', network='BTC')

179

print(f"BTC deposit address: {deposit_addr['address']}")

180

print(f"Tag: {deposit_addr.get('tag', 'None')}")

181

182

# Withdraw (requires withdrawal permissions)

183

withdraw_result = client.withdraw(

184

coin='BTC',

185

address='bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',

186

amount=0.001,

187

network='BTC'

188

)

189

print(f"Withdrawal ID: {withdraw_result['id']}")

190

```

191

192

### Universal Transfer

193

194

Transfer assets between different Binance account types.

195

196

```python { .api }

197

def universal_transfer(self, **params): ...

198

def get_universal_transfer_history(self, **params): ...

199

```

200

201

#### Usage Examples

202

203

```python

204

# Transfer from spot to futures account

205

transfer_result = client.universal_transfer(

206

type='MAIN_UMFUTURE', # Main account to USD-M Futures

207

asset='USDT',

208

amount=100.0

209

)

210

print(f"Transfer ID: {transfer_result['tranId']}")

211

212

# Get transfer history

213

transfer_history = client.get_universal_transfer_history(

214

type='MAIN_UMFUTURE',

215

limit=100

216

)

217

218

for transfer in transfer_history['rows']:

219

print(f"Amount: {transfer['amount']} {transfer['asset']}")

220

print(f"Status: {transfer['status']}")

221

print(f"Time: {transfer['timestamp']}")

222

```

223

224

### Funding Wallet

225

226

Operations for the funding wallet.

227

228

```python { .api }

229

def funding_wallet(self, **params): ...

230

def get_user_asset(self, **params): ...

231

```

232

233

#### Usage Examples

234

235

```python

236

# Get funding wallet balance

237

funding_balance = client.funding_wallet()

238

for balance in funding_balance:

239

if float(balance['free']) > 0:

240

print(f"{balance['asset']}: {balance['free']}")

241

242

# Get user asset information

243

user_assets = client.get_user_asset()

244

for asset in user_assets:

245

if float(asset['free']) > 0:

246

print(f"{asset['asset']}: Free={asset['free']}, Locked={asset['locked']}, Freeze={asset['freeze']}, Withdrawing={asset['withdrawing']}")

247

```

248

249

### API Key Management

250

251

Monitor API key usage and restrictions.

252

253

```python { .api }

254

def get_account_api_trading_status(self, **params): ...

255

def get_account_api_permissions(self, **params): ...

256

```

257

258

#### Usage Examples

259

260

```python

261

# Check if API key is restricted

262

api_status = client.get_account_api_trading_status()

263

data = api_status['data']

264

265

print(f"API locked: {data['isLocked']}")

266

print(f"Planned recover time: {data['plannedRecoverTime']}")

267

268

if data['triggerCondition']:

269

print(f"Trigger conditions: {data['triggerCondition']}")

270

271

# Get detailed API permissions

272

permissions = client.get_account_api_permissions()

273

perms = permissions['data']

274

275

print(f"IP restrict: {perms['ipRestrict']}")

276

print(f"Created: {perms['createTime']}")

277

print(f"Enable withdrawals: {perms['enableWithdrawals']}")

278

print(f"Enable reading: {perms['enableReading']}")

279

print(f"Enable spot trading: {perms['enableSpotAndMarginTrading']}")

280

print(f"Enable futures: {perms['enableFutures']}")

281

print(f"Enable margin: {perms['enableMargin']}")

282

print(f"Enable options: {perms['enableVanillaOptions']}")

283

```

284

285

### Rate Limiting Information

286

287

Monitor current rate limit usage.

288

289

```python { .api }

290

def get_current_order_count(self, **params): ...

291

```

292

293

#### Usage Examples

294

295

```python

296

# Check current order count and rate limits

297

order_count = client.get_current_order_count()

298

299

for limit in order_count:

300

print(f"Rate limit type: {limit['rateLimitType']}")

301

print(f"Interval: {limit['intervalNum']} {limit['interval']}")

302

print(f"Usage: {limit['count']}/{limit['limit']}")

303

```

304

305

### Account Allocations

306

307

Get allocation information for trades.

308

309

```python { .api }

310

def get_allocations(self, **params): ...

311

```

312

313

#### Usage Examples

314

315

```python

316

# Get recent allocations

317

allocations = client.get_allocations(symbol='BTCUSDT', limit=100)

318

319

for allocation in allocations['allocations']:

320

print(f"Symbol: {allocation['symbol']}")

321

print(f"Allocation ID: {allocation['allocationId']}")

322

print(f"Type: {allocation['allocationType']}")

323

print(f"Quantity: {allocation['qty']}")

324

print(f"Quote quantity: {allocation['quoteQty']}")

325

```

326

327

This comprehensive account management functionality provides complete control over account information, balances, trading history, and wallet operations across all Binance account types.