sammchardy / python-binance

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

Is testnet parameter working? #1186

Open chatlourd opened 2 years ago

chatlourd commented 2 years ago

I keep getting binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action. error when trying to use the testnet by setting the testnet parameter to True client = await AsyncClient.create(api_key, api_secret, testnet=True)

I'm using the api key and secret given at the bottom of testnet.binancefuture.com and it works correctly when I connect to biance API with the same key and secret using CCXT library for example so I know the key is correct and functional. Meanwhile I don't get an error when I connect to the live trading verison.

Has anyone else had any issues? I really can't see what I am doing wrong.

harper1999 commented 2 years ago

I got binance.exceptions.BinanceAPIException: APIError(code=0): Invalid JSON error message from Binance:

GonzaloMurillo commented 1 year ago

This is how I do it: 1) I have a boolean test, that I switch on / off to TRUE when I want to use the test 2) I have this code: if(test): self.api_key = "OwRVV9y4FLFfOzhihszzDMqfW7YRnBLRS1aFH3cGySjqTiczxSH2mFJ2d9axYOQI" self.api_secret = "wiJwfRu7bZKl96OIJkGFK8EVtiiTZ5gdlE4QKxFsyr59V6pUUnvEi9aG2TZ9z5xG"

This is required to change the API_URL endpoint

        self.client.API_URL = 'https://testnet.binance.vision/api'

I hope it helps

Gonzalo Murillo www.mrbot.es