BinanceAPIException: APIError(code=0): Invalid JSON error message from Binance:

Hello, i’m running a script in python and works fine for several hours, and suddenly stop running and this error appears…

BinanceAPIException: APIError(code=0): Invalid JSON error message from Binance:

403 Forbidden

403 Forbidden

'''

this is the part of the code that make the error call

def get_symbols(pair: str):
#client = binance.Client()
exchange_info = client.futures_exchange_info()
symbols = [x[‘symbol’] for x in exchange_info[‘symbols’]]
selected_symbols = list(filter(lambda x: x.endswith(pair),symbols))
selected_symbols = [x for x in selected_symbols if ‘BUSD’ not in x]
“”“selected_symbols = [x for x in selected_symbols if ‘DOWN’ not in x]
selected_symbols = [x for x in selected_symbols if ‘BULL’ not in x]
selected_symbols = [x for x in selected_symbols if ‘BEAR’ not in x]”“”
selected_symbols = [i for i in selected_symbols if all(j not in i for j in exclude)]
#print(f’{len(symbols)} {len(selected_symbols)} {selected_symbols}')
return selected_symbols

Hey,
Have a look at this post: How to deal with HTTP status code at Binance API?

If you can’t fix your issue with it, it may be related to the library you are using. I would therefore suggest you to try the Binance official library: binance-futures-connector-python/binance/um_futures/market.py at main · binance/binance-futures-connector-python · GitHub

1 Like