sammchardy / python-binance

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

binance.exceptions.BinanceAPIException: APIError(code=-1000): Request method 'POST' not supported #672

Open gabroliveros opened 3 years ago

gabroliveros commented 3 years ago

Hi, can you help me please with this error. I did change value of recvWindow and sinchronize my clock and continue obtaining the same.

tbrodbeck commented 3 years ago

I have the same error when calling client.get_asset_dividend_history() I dont know if this is related.


client.get_asset_dividend_history()
---------------------------------------------------------------------------
BinanceAPIException                       Traceback (most recent call last)
<ipython-input-11-fcfe2fd742ce> in <module>
----> 1 client.get_asset_dividend_history()

/usr/local/lib/python3.9/site-packages/binance/client.py in get_asset_dividend_history(self, **params)
   2046 
   2047         """
-> 2048         return self._request_margin_api('post', 'asset/assetDividend', True, data=params)
   2049 
   2050     def make_universal_transfer(self, **params):

/usr/local/lib/python3.9/site-packages/binance/client.py in _request_margin_api(self, method, path, signed, **kwargs)
    210         uri = self._create_margin_api_uri(path)
    211 
--> 212         return self._request(method, uri, signed, **kwargs)
    213 
    214     def _request_website(self, method, path, signed=False, **kwargs):

/usr/local/lib/python3.9/site-packages/binance/client.py in _request(self, method, uri, signed, force_params, **kwargs)
    195 
    196         self.response = getattr(self.session, method)(uri, **kwargs)
--> 197         return self._handle_response()
    198 
    199     def _request_api(self, method, path, signed=False, version=PUBLIC_API_VERSION, **kwargs):

/usr/local/lib/python3.9/site-packages/binance/client.py in _handle_response(self)
    228         """
    229         if not str(self.response.status_code).startswith('2'):
--> 230             raise BinanceAPIException(self.response)
    231         try:
    232             return self.response.json()

BinanceAPIException: APIError(code=-1000): Request method 'POST' not supported
gabroliveros commented 3 years ago

Yes @tbrodbeck, I obtain this error when I call

client.get_asset_dividend_history()

With params is the same.

LucEnden commented 3 years ago

I get the exact same exception by just calling the example given in the documentation:

result = client.get_asset_dividend_history()

No parameters given

LucEnden commented 3 years ago

Is it possible this issue occurs because the API is set to read-only? Mine currently is and I'm to new/afraid to take it of read-only mode to test this.

EtWnn commented 3 years ago

This error occurs in the latest stable version but not in the latest version of python-binance where the request type has been changed from POST to GET. So either you pip install the lastest non stable version, or you run directly the line: client._request_margin_api('get', 'asset/assetDividend', True, data=params) instead of client.get_asset_dividend_history()

gabroliveros commented 3 years ago

This error occurs in the latest stable version but not in the latest version of python-binance where the request type has been changed from POST to GET. So either you pip install the lastest non stable version, or you run directly the line: client._request_margin_api('get', 'asset/assetDividend', True, data=params) instead of client.get_asset_dividend_history()

Thank @EtWnn. I have tried: client._request_margin_api('get', 'asset/assetDividend', True, data=params) Unfortunately, it does not return the result corresponding to the history of an asset. It only gives me the distributions that I have received, for example TWT.

I used params= {'symbol':'BTCUSDT'}

EtWnn commented 3 years ago

Dividends are the gains you get from simply holding an asset. So dividends are relative to an asset (ex: 'TWT') and not a trading pair (ex: 'BTCUSDT').

It only gives me the distributions that I have received, for example TWT.

This is the normal behaviour, you can check on the binance API documentation

Unfortunately, it does not return the result corresponding to the history of an asset

I don't know the Binance API in full, but I did not see an endpoint to get the balance history of an asset. So if that's what you are looking for, you may have to reconstruct it from trades, transferts, deposits, withdraws and all the other asset movements that have been made on your account.