ccxt.base.errors.AuthenticationError: binance {"code":-2008,"msg":"Invalid Api-Key ID."}

I’m testing my ccxt python code on testnet binance futures.

I copy pasted the API Keys from testnet binance futures.

For some reason, I’m getting this error :

ccxt.base.errors.AuthenticationError: binance {“code”:-2008,“msg”:“Invalid Api-Key ID.”}

My API keys are hidden in another file, and I’ve double-checked them already.
I don’t see anything wrong with any of my parameters.

This is my code

import ccxt
import dontshare_config as ds

binance = ccxt.binance(

'apiKey': ds.TxP3_KEY,
'secret': ds.TxP3_SECRET,
'enableRateLimit': True,

'options': {
    'defaultType': 'future',

    'urls': {
        'api': '',
        'test': '',


Get the account balance on the testnet
balance = binance.fetch_balance()

Print the account balance

What could be the issue here?

I see you’re using CCXT which is a 3rd party library. You can try what was suggested in this answer in order to correctly tell CCXT to use the Testnet: python - how to tell ccxt to use binance / bybit testnet - Stack Overflow