ccxt: Why is my APIKey ID considered invalid?
Operating System
Windows 10 64-bit
Programming Languages
python
CCXT Version
4.0.36
Description
Every time I execute the following code on VS Code, instead of creating a sell order, it just gives this error:
An error occurred while placing the sell order: binance {“code”:-2008,“msg”:“Invalid Api-Key ID.”}
Code
import ccxt
api_key = "'MY_API_KEY'"
secret_key = "MY_SECRET_KEY"
binance = ccxt.binance({
'apiKey': api_key,
'secret': secret_key,
'enableRateLimit': True,
'headers':{
'X-MBX-APIKEY': api_key,
},
'options': {
'adjustForTimeDifference': True, # exchange-specific option
}
})
symbol = 'BTC/TUSD'
quantity = 0.001
price = 60000.0
try:
order = binance.create_market_sell_order(symbol, quantity)
print("Sell order placed successfully!")
print("Order details:")
print(order)
except Exception as e:
print("An error occurred while placing the sell order:")
print(str(e))
I also put other settings in the autentication section of the code, such as:
'enableRateLimit': True, 'headers':{ 'X-MBX-APIKEY': api_key,
and
'options': { 'adjustForTimeDifference': True, # exchange-specific option }
But the result doesn’t change, it still gives the same error.
I even tried using a VPN and moved my location to Switzerland,Spain and France, but the outcome doesn’t change.
If someone could help me on this, I would apreciate it a lot. I’ll try to respond as fast as possible to everyone who will try to help me.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (10 by maintainers)
@ttodua For the API I’m not sending “MY_API_KEY” but the actual API key. For ccxt I’m using version 4.0.36 (which should be the latest) For python I’m using 3.8 (which is not the latest) I’ll try to use the newer version of Python and see if the problem is fixed.
@ttodua, i didn’t put my API Key to “MY_API_KEY”, in the verbose response there is actually my API Key, i censored It for obvious reason.
@GAMinsect make sure your api key and secret are set up correctly, compare to the exchange website and check permissions.