sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.91k stars 2.19k forks source link

How to get Staking data? #1153

Open alexandrechoske opened 2 years ago

alexandrechoske commented 2 years ago

Hi, is there a way to retrieve the staking data trhough the API?

I Found this on Binance API.

https://docs.binance.org/api-reference/dex-api/staking.html

But did not find any related paths in Python-Binance

Thanks in advance.

alexandrechoske commented 2 years ago

Sorry but I didnt understand, what is benc13? And syncrhonize where? I am just using the python-binance api...

halfelf commented 2 years ago

What you found is staking doc for binance chain, not the centralized exchange.

AFAIK, there is no way to get staking data through any existing API in binance exchange.

Reference thread: https://dev.binance.vision/t/earn-locked-staking/1453

halfelf commented 2 years ago

Good news, binance has added staking API since 28th Apr. This could be done by calling some "private" methods in this library.

GET /sapi/v1/staking/productList to get Staking product list
POST /sapi/v1/staking/purchase to stake product
POST /sapi/v1/staking/redeem to redeem product
GET /sapi/v1/staking/position to get Staking product holding position
GET /sapi/v1/staking/stakingRecord to inquiry Staking history records
POST /sapi/v1/staking/setAutoStaking to set Auto Staking function
GET /sapi/v1/staking/personalLeftQuota to inquiry Staking left quota
solipsist01 commented 2 years ago

How does one create a private method? I couldn't find this in the documentation, or any issues with an example. I'm able to make the calls manually within python, but i'd rather use this module, cuz them i'm sure i'm not rate limiting. (perhaps somewhat lazy)

halfelf commented 2 years ago

@solipsist01 You don't "create" private method. This library has wrapped the http request well. The only thing you need is to find the right endpoint and params.

I have a forked project from this lib and wrapped these API.

ref: https://github.com/halfelf/trio-binance/blob/master/trio_binance/client.py#L1173

Similarly, one can directly call those "margin request" method in this lib:

client._request_margin_api('get', 'staking/productList', True, data={'product': 'STAKING'})

solipsist01 commented 2 years ago

Was anyone able to use GET /sapi/v1/staking/personalLeftQuota(HMAC SHA256), or the POST /sapi/v1/staking/purchase (HMAC SHA256) endpoint ? These endpoints ask for a productId. but only a projectId is supplied in the output of the GET /sapi/v1/staking/productList (HMAC SHA256) endpoint.

No endpoint gives me a productId.

when i use projectId i get the error that GET isn't supported for this endpoint.

Menniti commented 1 year ago

Hello, I`m having the same issue, I need to call endpoints such as GET /sapi/v1/staking/productList and /sapi/v1/staking/stakingRecord, but I could not found way to do it.

Anyone have done this before? Thanks