Changing base endpoint.

Hello everyone,
when using the REST API, the default endpoint is ‘https://api.binance.com’, and I tried to change it this way:

from binance.client import Client

client = Client(api_key, api_secret)
client.API_URL = 'https://api4.binance.com'

but I’m receiving this error:

Error: APIError(code=0): Invalid JSON error message from Binance: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
.
Error: APIError(code=0): Invalid JSON error message from Binance: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
. Try again in 0.005 seconds.

How can I change the endpoint?

Thank you.

Hey,
I think you’ll need to set it when initializing the client by adding one of the values listed here as the base_endpoint parameter.
If you’re using the Binance Python library, you can find an explanation in the readme.

1 Like

Thanks!
I use the ‘python-binance’ library, and the only way I know to change the base endpoint is the one I showed above. I can’t figure out how to do it otherwise.
Anyway, I followed your other advice and modified my bot using the ‘binance-connector-python’ library, and now I can change the base endpoint. I hope to see an improvement in performance.