Binance API Python Invalid API-KEY

Hi all, I went to testnet Binance futures found my API keys and wrote the code:

from binance.client import Client
from binance.exceptions import BinanceAPIException, BinanceOrderException
try:
    buy_order = client.create_test_order(symbol='ETHUSDT', side='BUY', type='MARKET', quantity=1)
except BinanceAPIException as e:
    print(e)
except BinanceOrderException as e:
    print(e)

The code gave an error:

APIError(code=-2015): Invalid API-key, IP, or permissions for action.

There are no IP and API access settings, just a key bar at the bottom of the page. And I don’t understand what the error is, I have used many options, including binance-futures-connector with the code suggested on the documentation page, but the error is still the same. Praying for help!

Hi akira-dono!

Is that all the code of the script?

Where are you putting the api key?

Hi,

It seems you’re trying to use a Testnet API key on the live/production API. You must set the base_url to the testnet URL otherwise it will use the live base_url by default.