bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
385 stars 129 forks source link

Add rate limit reset timestamp and response headers in Error #135

Closed sheungon closed 1 year ago

sheungon commented 1 year ago

Return "rate_limit_reset_timestamp" on 403 breached IP rate limit. Return response headers on FailedRequestError.

dextertd commented 1 year ago

I think this PR is confusing the two Bybit rate limits.

  1. API rate limit which is returns X-Bapi-Limit-Reset-Timestamp.
  2. IP rate limit which does not return any kind of reset timestamp, it just returns 403 Access Denied.

This PR seems to want to detect 403, and then parse for X-Bapi-Limit-Reset-Timestamp, although that is not possible.

dextertd commented 1 year ago

Let me know if I am misunderstanding something...

sheungon commented 1 year ago

Let me know if I am misunderstanding something...

Correct. That's what I'm trying to do.

From Bybit document, X-Bapi-Limit-Reset-Timestamp - the timestamp indicating when your request limit resets if you have exceeded your rate_limit. Otherwise, this is just the current timestamp. Ref, https://bybit-exchange.github.io/docs/v5/rate-limit

From this, I thought the "reset timestamp" will be a meaningful value only when rate limit exceeded. And for "rate limit exceeded", I thought that was 403 error. Looks like I misunderstood again ;D

So, "Rate Limit exceeded" != "IP banned"

In this case, all I need will be the response headers (for rate limit reached) then. Let me create another PR for this.