client.get_account_status() error (python)

Hi guys,
I m trying to execute this:
status = client.get_account_status()
and return me this error:
C:\Users\nikho\OneDrive\Escritorio\GHB\PROGRAMACION\TRADE>python try1.py
Traceback (most recent call last):
File “try1.py”, line 6, in
status = client.get_account_status()
File “C:\Users\nikho\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py”, line 1880, in get_account_status
if not res[‘success’]:
KeyError: ‘success’

My api key and secret are correctly. Also dont allow me to use another functions like: client.get_my_trades() or client.get_asset_details(). I guess is the same problem

This means your key/secret are wrong. I can get them just fine:

>>> binance.get_account_status()
{'msg': 'Normal', 'success': True}

No way, cause I just copy it and paste. no more than this

If you’re sure your key/secret are correct, read this - https://binance-docs.github.io/apidocs/spot/en/#account-status-user_data and call the endpoint directly. If this way works, then it’s the function get_account_status that has issue, go there - https://github.com/sammchardy/python-binance/ and raise this one. It’s a 3rd-party library.

I think it’s the library code:

When there is an error, the res dictionary won’t have a success key at all, so checking for it’s existence will raise KeyError. The code should either be changed to if not res.get('success'):, or wrap the dictionary access in a try/catch and handle the KeyError.

Now having said that, I am experiencing what I think is a related issue in that my API Key and Secret work fine for anything related to market data, e.g. the REST API and Websocket endpoints allow me to query prices - but anything related to account, like getting the account status, submitting test orders, etc. reject the API key as invalid. Any thoughts as to what would cause that? It is definitely not library related. I’ve verified my IP is included in the trust ips section, and I’ve enabled spot trading, but to no avial.

Most market data doesn’t require API key/secret so it doesn’t mean anything.

This means your key/secret has problem.

Again read my previous answer:

If you’re sure your key/secret are correct, read this - https://binance-docs.github.io/apidocs/spot/en/#account-status-user_data 5 and call the endpoint directly. If this way works, then it’s the function get_account_status that has issue, go there - https://github.com/sammchardy/python-binance/ 3 and raise this one. It’s a 3rd-party library.

I created a separate post shortly after replying here that provides more detail:

But in short - I tried the binance example and all signed requests reject the API key, and I highly doubt the key/secret are the problem as I’ve created an entirely new pair just to be safe and it still does not work.

Final solution - Install POSTMAN and import the collections from https://github.com/binance/binance-api-postman (there’re instructions)
Then try your api key/secret there. Good luck