How to deal with HTTP status code at Binance API?

To prevent abuse of Binance API, there is http request limit rules that every client needs to follow. There are many details in the API document (Binance API Documentation), here is just a summary of them.

If a client choose to ignore the limit and keep sending request to server over the limit, it will see status code of:

200 -> 429 -> 418 -> 403

  • 200
    • This is the success status code.
    • Nothing is wrong, the client is doing good.
  • 429
    • This is an ERROR code from server
    • The client should slow down
    • The response header has a retry-after value in seconds, telling how long the client has to rest.
  • 418
    • This is a WARNING from server.
    • The client should stop sending another request immediately.
    • The response header has a retry-after value in seconds, telling how long the client has to rest.
    • The error message also give the timestamp that client should wait until then.
    • No one knows when the client will receive the further punishment.
  • 403
    • The client IP is blocked.
    • No one knows when the IP will be removed out of the blacklist.
    • No one can help to remove the IP out of the blacklist. The Customer Support is NOT helpful on this.
    • Ban duration can be from 2 minutes to 3 days.
    • Waiting is the only thing you can do at this stage.

Additionally there is a 451 error which will be displayed immediately upon accessing the endpoint from a restricted region:

  • 451
    • The region from where your request was sent is restricted from accessing this endpoint.
    • Some regions/areas may be restricted to access some products or services.
    • For example, US residents are not allowed to access Binance.com .
    • If you are a US trading client, please consider trading on Binance.us
    • If you are not a US resident but are using servers or infrastructure based in the US, consider choosing a different region to host your application.