0
# Staking and Mining Operations
1
2
Comprehensive staking and mining functionality including DeFi staking, ETH/SOL staking, locked staking products, and mining operations. Provides access to staking rewards, mining statistics, and portfolio management across various blockchain networks.
3
4
## Capabilities
5
6
### General Staking Operations
7
8
Core staking functionality for various staking products and services.
9
10
```python { .api }
11
def get_staking_product_list(self, **params): ...
12
def purchase_staking_product(self, **params): ...
13
def redeem_staking_product(self, **params): ...
14
def get_staking_position(self, **params): ...
15
def get_staking_purchase_history(self, **params): ...
16
def set_auto_staking(self, **params): ...
17
```
18
19
#### Usage Examples
20
21
```python
22
# Get available staking products
23
staking_products = client.get_staking_product_list(
24
product='STAKING', # STAKING, F_DEFI, L_DEFI
25
current=1,
26
size=20
27
)
28
29
for product in staking_products:
30
print(f"Product ID: {product['productId']}")
31
print(f"Asset: {product['asset']}")
32
print(f"APY: {product['apy']}%")
33
print(f"Duration: {product['duration']} days")
34
print(f"Min purchase amount: {product['minPurchaseAmount']}")
35
print(f"Can purchase: {product['canPurchase']}")
36
37
# Purchase a staking product
38
purchase = client.purchase_staking_product(
39
product='STAKING',
40
productId='product_123',
41
amount=100,
42
renewable=True # Auto-renew when expired
43
)
44
45
print(f"Purchase ID: {purchase['purchaseId']}")
46
print(f"Status: {purchase['status']}")
47
48
# Get current staking positions
49
positions = client.get_staking_position(
50
product='STAKING', # STAKING, F_DEFI, L_DEFI
51
current=1,
52
size=50
53
)
54
55
for position in positions:
56
print(f"Position ID: {position['positionId']}")
57
print(f"Asset: {position['asset']}")
58
print(f"Amount: {position['amount']}")
59
print(f"APY: {position['apy']}%")
60
print(f"Status: {position['status']}")
61
print(f"Purchase time: {position['purchaseTime']}")
62
print(f"Accrual days: {position['accrualDays']}")
63
64
# Redeem a staking position
65
redemption = client.redeem_staking_product(
66
product='STAKING',
67
positionId=position['positionId'],
68
amount=50 # Partial redemption
69
)
70
71
# Get purchase history
72
history = client.get_staking_purchase_history(
73
product='STAKING',
74
current=1,
75
size=20
76
)
77
78
# Set auto-staking for renewals
79
auto_staking = client.set_auto_staking(
80
product='L_DEFI', # Locked DeFi
81
positionId='position_456',
82
renewable=True
83
)
84
```
85
86
### US Staking Operations
87
88
Specialized staking operations for US users with different product offerings.
89
90
```python { .api }
91
def get_staking_asset_us(self, **params): ...
92
def get_staking_balance_us(self, **params): ...
93
def get_staking_history_us(self, **params): ...
94
def get_staking_rewards_history_us(self, **params): ...
95
```
96
97
#### Usage Examples
98
99
```python
100
# Get US staking assets
101
us_assets = client.get_staking_asset_us()
102
for asset in us_assets:
103
print(f"Asset: {asset['asset']}")
104
print(f"APY range: {asset['minApy']}% - {asset['maxApy']}%")
105
print(f"Available for staking: {asset['canStake']}")
106
107
# Get US staking balances
108
us_balances = client.get_staking_balance_us()
109
total_value = 0
110
for balance in us_balances:
111
print(f"Asset: {balance['asset']}")
112
print(f"Staked amount: {balance['amount']}")
113
print(f"USD value: ${balance['usdValue']}")
114
total_value += float(balance['usdValue'])
115
116
print(f"Total staking value: ${total_value:.2f}")
117
118
# Get US staking history
119
us_history = client.get_staking_history_us(
120
product='STAKING',
121
txnType='SUBSCRIPTION', # SUBSCRIPTION, REDEMPTION
122
current=1,
123
size=20
124
)
125
126
# Get US staking rewards history
127
us_rewards = client.get_staking_rewards_history_us(
128
asset='USDT',
129
current=1,
130
size=100
131
)
132
133
for reward in us_rewards:
134
print(f"Asset: {reward['asset']}")
135
print(f"Amount: {reward['amount']}")
136
print(f"Time: {reward['time']}")
137
print(f"Type: {reward['type']}")
138
```
139
140
### ETH Staking Operations
141
142
Ethereum-specific staking functionality including ETH 2.0 staking and WBETH operations.
143
144
```python { .api }
145
def margin_v2_get_eth_staking_account(self, **params): ...
146
def margin_v2_post_eth_staking_eth_stake(self, **params): ...
147
def margin_v1_post_eth_staking_eth_redeem(self, **params): ...
148
def margin_v1_post_eth_staking_wbeth_wrap(self, **params): ...
149
def margin_v1_post_eth_staking_wbeth_unwrap(self, **params): ...
150
def margin_v1_get_eth_staking_eth_history_staking_history(self, **params): ...
151
def margin_v1_get_eth_staking_eth_history_redemption_history(self, **params): ...
152
def margin_v1_get_eth_staking_eth_history_wbeth_rewards_history(self, **params): ...
153
```
154
155
#### Usage Examples
156
157
```python
158
# Get ETH staking account information
159
eth_account = client.margin_v2_get_eth_staking_account()
160
print(f"Total ETH staked: {eth_account['totalAmount']}")
161
print(f"WBETH balance: {eth_account['wbethAmount']}")
162
print(f"Estimated APR: {eth_account['estimatedApr']}%")
163
print(f"Last reward distribution: {eth_account['lastRewardDistribution']}")
164
165
# Stake ETH
166
eth_stake = client.margin_v2_post_eth_staking_eth_stake(
167
amount=1.0 # Stake 1 ETH
168
)
169
print(f"Staking success: {eth_stake['success']}")
170
print(f"WBETH received: {eth_stake['wbethAmount']}")
171
172
# Redeem ETH from staking
173
eth_redeem = client.margin_v1_post_eth_staking_eth_redeem(
174
amount=0.5, # Redeem 0.5 ETH worth
175
type=1 # 1: fast redemption (with fee), 0: slow redemption
176
)
177
178
# Wrap ETH to WBETH
179
wbeth_wrap = client.margin_v1_post_eth_staking_wbeth_wrap(
180
amount=0.1
181
)
182
183
# Unwrap WBETH to ETH
184
wbeth_unwrap = client.margin_v1_post_eth_staking_wbeth_unwrap(
185
amount=0.1
186
)
187
188
# Get ETH staking history
189
eth_history = client.margin_v1_get_eth_staking_eth_history_staking_history(
190
current=1,
191
size=50
192
)
193
194
for record in eth_history['rows']:
195
print(f"Time: {record['time']}")
196
print(f"ETH amount: {record['amount']}")
197
print(f"WBETH received: {record['wbethAmount']}")
198
print(f"Status: {record['status']}")
199
200
# Get WBETH rewards history
201
wbeth_rewards = client.margin_v1_get_eth_staking_eth_history_wbeth_rewards_history(
202
current=1,
203
size=100
204
)
205
206
for reward in wbeth_rewards['rows']:
207
print(f"Date: {reward['time']}")
208
print(f"Holding amount: {reward['holdingAmount']}")
209
print(f"Annualized rate: {reward['annualizedRate']}%")
210
print(f"Rewards: {reward['rewards']}")
211
```
212
213
### SOL Staking Operations
214
215
Solana-specific staking functionality including BNSOL rewards and validator staking.
216
217
```python { .api }
218
def margin_v1_get_sol_staking_account(self, **params): ...
219
def margin_v1_post_sol_staking_sol_stake(self, **params): ...
220
def margin_v1_post_sol_staking_sol_redeem(self, **params): ...
221
def margin_v1_post_sol_staking_sol_claim(self, **params): ...
222
def margin_v1_get_sol_staking_sol_quota(self, **params): ...
223
def margin_v1_get_sol_staking_sol_history_staking_history(self, **params): ...
224
def margin_v1_get_sol_staking_sol_history_redemption_history(self, **params): ...
225
def margin_v1_get_sol_staking_sol_history_bnsol_rewards_history(self, **params): ...
226
def margin_v1_get_sol_staking_sol_history_boost_rewards_history(self, **params): ...
227
def margin_v1_get_sol_staking_sol_history_unclaimed_rewards(self, **params): ...
228
def margin_v1_get_sol_staking_sol_history_rate_history(self, **params): ...
229
```
230
231
#### Usage Examples
232
233
```python
234
# Get SOL staking account information
235
sol_account = client.margin_v1_get_sol_staking_account()
236
print(f"Total SOL staked: {sol_account['totalAmountInSOL']}")
237
print(f"BNSOL balance: {sol_account['bnsolAmount']}")
238
print(f"Unclaimed rewards: {sol_account['unclaimedRewards']}")
239
print(f"Estimated APR: {sol_account['estimatedApr']}%")
240
241
# Stake SOL
242
sol_stake = client.margin_v1_post_sol_staking_sol_stake(
243
amount=10.0 # Stake 10 SOL
244
)
245
print(f"Staking transaction ID: {sol_stake['transactionId']}")
246
print(f"BNSOL received: {sol_stake['bnsolAmount']}")
247
248
# Check SOL staking quota
249
sol_quota = client.margin_v1_get_sol_staking_sol_quota()
250
print(f"Available quota: {sol_quota['leftQuota']} SOL")
251
print(f"Minimum stake: {sol_quota['minAmount']} SOL")
252
253
# Redeem SOL from staking
254
sol_redeem = client.margin_v1_post_sol_staking_sol_redeem(
255
amount=5.0, # Redeem 5 SOL worth
256
type=1 # 1: fast redemption, 0: slow redemption
257
)
258
259
# Claim SOL staking rewards
260
claim_rewards = client.margin_v1_post_sol_staking_sol_claim()
261
print(f"Claimed amount: {claim_rewards['amount']}")
262
263
# Get SOL staking history
264
sol_history = client.margin_v1_get_sol_staking_sol_history_staking_history(
265
current=1,
266
size=50
267
)
268
269
# Get BNSOL rewards history
270
bnsol_rewards = client.margin_v1_get_sol_staking_sol_history_bnsol_rewards_history(
271
current=1,
272
size=100
273
)
274
275
for reward in bnsol_rewards['rows']:
276
print(f"Date: {reward['time']}")
277
print(f"Holding: {reward['bnsolHolding']} BNSOL")
278
print(f"Rewards: {reward['bnsolRewards']} BNSOL")
279
280
# Get boost rewards history
281
boost_rewards = client.margin_v1_get_sol_staking_sol_history_boost_rewards_history(
282
current=1,
283
size=100
284
)
285
286
# Get rate history
287
rate_history = client.margin_v1_get_sol_staking_sol_history_rate_history(
288
current=1,
289
size=30
290
)
291
292
for rate in rate_history['rows']:
293
print(f"Date: {rate['time']}")
294
print(f"Exchange rate: {rate['exchangeRate']}")
295
print(f"Annualized rate: {rate['annualizedRate']}%")
296
```
297
298
### General Staking Records
299
300
Cross-platform staking record management.
301
302
```python { .api }
303
def margin_v1_get_staking_staking_record(self, **params): ...
304
```
305
306
#### Usage Examples
307
308
```python
309
# Get comprehensive staking records
310
staking_records = client.margin_v1_get_staking_staking_record(
311
product='ETH', # ETH, SOL, or other supported assets
312
current=1,
313
size=100
314
)
315
316
for record in staking_records['rows']:
317
print(f"Asset: {record['asset']}")
318
print(f"Amount: {record['amount']}")
319
print(f"Status: {record['status']}")
320
print(f"APR: {record['apr']}%")
321
print(f"Time: {record['time']}")
322
print(f"Type: {record['type']}") # STAKE, REDEEM, REWARDS
323
```
324
325
## Staking Product Types
326
327
```python { .api }
328
# Staking product types
329
STAKING_PRODUCT_LOCKED = "STAKING" # Locked staking
330
STAKING_PRODUCT_DEFI_FLEXIBLE = "F_DEFI" # Flexible DeFi
331
STAKING_PRODUCT_DEFI_LOCKED = "L_DEFI" # Locked DeFi
332
333
# Staking transaction types
334
STAKING_TXN_SUBSCRIPTION = "SUBSCRIPTION"
335
STAKING_TXN_REDEMPTION = "REDEMPTION"
336
STAKING_TXN_INTEREST = "INTEREST"
337
338
# Staking status values
339
STAKING_STATUS_HOLDING = "HOLDING"
340
STAKING_STATUS_REDEEMED = "REDEEMED"
341
STAKING_STATUS_REWARDING = "REWARDING"
342
```
343
344
## Error Handling
345
346
```python
347
from binance import BinanceAPIException
348
349
try:
350
# Attempt to stake
351
stake_result = client.purchase_staking_product(
352
product='STAKING',
353
productId='product_123',
354
amount=100
355
)
356
357
except BinanceAPIException as e:
358
if e.code == -3020:
359
print("Insufficient balance for staking")
360
elif e.code == -3021:
361
print("Staking product not available")
362
elif e.code == -3022:
363
print("Amount below minimum staking requirement")
364
else:
365
print(f"Staking error: {e.message}")
366
```
367
368
## Rate Limiting
369
370
Staking operations are subject to specific rate limits:
371
372
- Product queries: 1 request per 5 seconds
373
- Staking operations: 1 request per 3 seconds
374
- History queries: 5 requests per 1 minute
375
376
The Staking and Mining API provides comprehensive access to Binance's staking ecosystem with support for multiple blockchain networks, flexible and locked products, and detailed reward tracking across all supported assets.