Closed themarkwilliams closed 1 year ago
Hi,
I just tested this personally and can confirm it is working as expected. Please make sure you're using the latest version of binance-connector-python
. The below code is working for me on v1.18.0. I also tested it with staking_product_position
and staking_product_list
. I'm using Python version 3.10.6.
from binance.spot import Spot
from datetime import datetime
apiKey = "<APIKEY>"
secretKey = "<APISECRET>"
start = int(datetime(2022, 8, 15, 23, 59, 59).timestamp() * 1000)
end = int(datetime(2022, 11, 15, 23, 59, 59).timestamp() * 1000)
client = Spot(apiKey, secretKey)
print(client.staking_history(product='STAKING', txnType='INTEREST', startTime=start, endTime=end))
Hi,
I just tested this personally and can confirm it is working as expected. Please make sure you're using the latest version of
binance-connector-python
. The below code is working for me on v1.18.0. I also tested it withstaking_product_position
andstaking_product_list
. I'm using Python version 3.10.6.from binance.spot import Spot from datetime import datetime apiKey = "<APIKEY>" secretKey = "<APISECRET>" start = int(datetime(2022, 8, 15, 23, 59, 59).timestamp() * 1000) end = int(datetime(2022, 11, 15, 23, 59, 59).timestamp() * 1000) client = Spot(apiKey, secretKey) print(client.staking_history(product='STAKING', txnType='INTEREST', startTime=start, endTime=end))
Thanks for the response.
If I try your code above, I get an ClientError of "Invalid Api-Key ID'.
I believe that's because I'm in the US and I have to specify base_url="https://api.binance.us"
When I use change this line of your code client = Spot(apiKey, secretKey)
to client = Spot(apiKey, secretKey, base_url='https://api.binance.us')
, I get the same KeyError of 'code'.
Is there a different way I should specify the base_url?
This connector is designed on .com API, but the staking API from .us seems different.
Unfortunately the library will not work directly for your case, but as it's open source, please feel free to change the code based on your needs.
Issue subject
Trying to use the binance connector to interrogate staking history, but get a KeyError of 'code'
Expected behaviour
Calling client.staking_history(product='STAKING', txnType='INTEREST') I expect that the values for staking_history would be returned.
Actual behaviour
The above yields a KeyError exception of 'code' regardless of product or txnType specified.
Traceback (most recent call last): File "process.py", line 66, in
print(client.staking_history(product='STAKING', txnType='INTEREST'))
File "C:\Python310\lib\site-packages\binance\spot\staking.py", line 136, in staking_history
return self.sign_request("GET", url_path, params)
File "C:\Python310\lib\site-packages\binance\api.py", line 83, in sign_request
return self.send_request(http_method, url_path, payload)
File "C:\Python310\lib\site-packages\binance\api.py", line 117, in send_request
self._handle_exception(response)
File "C:\Python310\lib\site-packages\binance\api.py", line 170, in _handle_exception
raise ClientError(status_code, err["code"], err["msg"], response.headers)
KeyError: 'code'
Got the same error for staking_product_position and staking_product_list.
Environment
Provide any relevant information about your setup, such as: