How to make a futures testnet order via Python?

I am trying to test my program on my testnet account before I deploy it on to my real account.
I created an account and got the API keys from https://testnet.binancefuture.com/en/futures/BTCUSDT
However I am confused as to how I place an order on the testnet.

client = Client(api_key, secret_key)
client.futures_create_order(symbol='BTCUSDT', type=ORDER_TYPE_MARKET, side=SIDE_BUY, quantity=1)

leads to : 
binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action, request ip: 79.233.206.*** (censored for security reasons)

client = Client(api_key, secret_key)
client.create_test_order(symbol='BTCUSDT', type=ORDER_TYPE_MARKET, side=SIDE_BUY, quantity=1)

leads to: 
binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action. 

How do I place a testnet.futures-order?

class Client(object):

    API_URL = 'https://api.binance.{}/api'
    WITHDRAW_API_URL = 'https://api.binance.{}/wapi'
    MARGIN_API_URL = 'https://api.binance.{}/sapi'
    WEBSITE_URL = 'https://www.binance.{}'
    FUTURES_URL = 'https://fapi.binance.{}/fapi'
    PUBLIC_API_VERSION = 'v1'
    PRIVATE_API_VERSION = 'v3'
    WITHDRAW_API_VERSION = 'v3'
    MARGIN_API_VERSION = 'v1'
    FUTURES_API_VERSION = 'v1'

It does not appear to have such a parameter, but I could tamper with the class itself.

The docs tell me:
The REST baseurl for testnet is “https://testnet.binancefuture.com

When I change the FUTURES_URL = ‘https://testnet.binancefuture.{}/fapi’ it works, ty. :slight_smile:

1 Like

Мне помогло. Спасибо

you need to check if the Client class supporting testnet, maybe it has parameter to change the base url to testnet. Please check the library source code.

Hi @Christall
will you please tell me like how this issued resolved. Like how you changed the FUTURES_URL??

Could you please show your whole code? I am struggling with the same issue and I can’t seem to fix it. Thanks in advance

you have to write

client = Client(API_KEY, SECRET_KEY, testnet=True)
1 Like