-1

I am using the API from binance to create test order but it is showing me this error:

code of order request

response from the above code

When I log out from the desktop app and log in again it works, but after the first response it shows the above error. Again I have to log out and log in. As you can iamgine it is really painful.

The code :

order = client.create_test_order(symbol='BTCBUSD',type='MARKET', side ='BUY',quantity=0.005)
print(order)

The error:

Traceback (most recent call last):
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\main.py", line 69, in <module>
    order = client.create_test_order(symbol='BTCBUSD',type='MARKET', side ='BUY',quantity=0.005)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\venv\Lib\site-packages\binance\client.py", line 1825, in create_test_order
    return self._post('order/test', True, data=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\venv\Lib\site-packages\binance\client.py", line 417, in _post
    return self._request_api('post', path, signed, version, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\venv\Lib\site-packages\binance\client.py", line 377, in _request_api
    return self._request(method, uri, signed, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\venv\Lib\site-packages\binance\client.py", line 358, in _request
    return self._handle_response(self.response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\182_Suhel\PycharmProjects\learn_crypto\venv\Lib\site-packages\binance\client.py", line 367, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action.

I tried creating other API from the web site in the hope it will fix the problem but it didn't. Any help would be appreciated

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
suhel
  • 1
  • 1
  • Don't make us retype code from an image. Post your code, and the full error trace message, as text. – John Gordon Jul 29 '23 at 13:55
  • 1
    Looks like you can't use the same credentials to log in to the API and the desktop app at the same time. You have to pick one or the other. – John Gordon Jul 29 '23 at 14:28
  • post the code and not the pictures of code. Users need to be able to replicate the problem quickly, which text allows for (and pictures do not). [how to ask](https://stackoverflow.com/help/how-to-ask) – D.L Jul 29 '23 at 16:48

1 Answers1

0

Based on the method create_test_order, you should only call the API by testnet API key; Using prod API key will return this error.

Binance
  • 69
  • 6