Track rate limit response headers in base client
tiagosiebler opened this issue · comments
https://bybit-exchange.github.io/docs/v5/rate-limit
Track rate limit response headers any time an api call is processed. These could then be queried async via local state.
Similar system in my binance sdk:
I think it's a critical feature.
Maybe to make a fast patch it's possible to return the raw header in the response.data returned by BaseRestClient::get method.
At the moment I locally resolve the issue with this patch in BaseRestClient.js::_call :
return axios_1.default(options)
.then((response) => {
if (response.status == 200) {
response.data = {...response.data, headers: response.headers}; <---
return response.data;
}
throw response;
})
.catch((e) => this.parseException
I've just released an implementation (#293) that is disabled by default, but once enabled, includes these bapi header states in the response. Take a look at the PR comments for examples on how it looks.
To turn on the parser, just include the new setting in the RestClientV5 constructor:
const client = new RestClientV5({
parseAPIRateLimits: true,
});
Please let me know how you get on and if you notice any issues (although the mechanism is both very simple and protective). After some time, I may turn it on by default.