To ensure that the person with the best internet connection cannot overthrow the board, we set up some rate limits that you have to respect. We use headers to communicate our current rate limit setup.
For example:
HEADERS = {
# ... your Authorization headers
}
result = requests.get(
"<http://pixels.pythondiscord.com/get_pixels>",
headers=HEADERS
)
print(result.headers)
We are interested in the last four headers, prefixed by requests-
:
{
...,
'requests-remaining': '4',
'requests-limit': '5',
'requests-period': '10',
'requests-reset': '9.523'
}
Here is the meaning of each header:
requests-remaining
: (int) How many requests you are still allowed to do before waiting.requests-limit
: (int) How many requests you can do during a period.requests-period
: (int) Duration, in seconds, of the ratelimit period.requests-reset
: (float) How many seconds you must wait without sending a request before getting all your requests back. 0
if you still have all your requests.Do note that trying to send a request while requests-remaining
is 0 will result in a cooldown phase, where you won't be able to send any request for a longer time than the normal ratelimit period.
If for any reason this happens, you can check how long you have to still wait in the cooldown-reset
header.
We recommend you respect rate limits as much as possible, as running into cooldowns will slow you down.
You can also send a HEAD request to query the state of your rate-limits but without performing any action.
One possible setup would be to wait requests-reset
seconds when requests-remaining
reaches zero, but we won't give you any more hints!