Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binance API in python APIError(code=-1121): Invalid symbol

I am trying to code a binance Buy function. However the code

from binance.enums import *
order = client.create_order(symbol='DOGEUSDT', side = 'BUY',  type = 'MARKET', quantity = 475, timeInForce='GTC')

this code outputs > APIError(code=-1121): Invalid symbol.

Also, for the same symbol,

print(client.get_symbol_info(symbol="DOGEUSDT"))

ouptuts > None

The symbol DOGEUSDT exists is the orderbook. https://api.binance.com/api/v3/ticker/bookTicker I dont know why the same symbol I get from binance is invalid.

like image 459
Err0rBlade Avatar asked Aug 04 '26 07:08

Err0rBlade


2 Answers

Are you using the testnet? I had the same error, however when I removed testnet=True from the client initialization the error was resolved.

like image 181
Damian Games Avatar answered Aug 07 '26 04:08

Damian Games


two things can happen

  1. client.API_URL = https://testnet.binance.vision/api

in that case change it to

https://api.binance.com/api

  1. Client(api_key, secret_key, testnet=True)

in that case change testnet=False or delete it

like image 39
clara savelli Avatar answered Aug 07 '26 03:08

clara savelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!