In my application I want add checker to avoid rate limits. I understand
x-ratelimit-remaining-requests parameters. But confused about
x-ratelimit-reset-requests. Does it mean the limiter is going to be reset in 12 miliseconds(for following response header)?
The time until the rate limit (based on requests) resets to its initial state.
A unique and still undisclosed formula is used. 12ms means that after 12ms there will be no memory of your API call counting against you if you make no others.
However, cumulative calls within a period are a bit more tricky, will make that reported period grow, and the reset has little value to you then.
If you are going to be approaching the limit, for example, for a batch job, a good policy to write is to have a FIFO buffer, where you record the counts, tokens, and timestamps, and don’t expire the calls from that record until the period of its evaluation time is up. Then you total that unexpired pool and see if it is near exceeding your given limit, and hold off on more submissions until the last would exit.