Rate limits and errors¶
Rate limits¶
oxrpy spaces out your requests so you stay under Oxford's limits:
| Key | get_server_data and the helpers |
Other requests | Commands |
|---|---|---|---|
| Server key | 1 a second (bursts of 2) | 5 a second (bursts of 15) | 1 a second |
| App key (standard) | 20 a second (bursts of 40), shared | shared with the first column | 2 a second (bursts of 5) |
If you do get rate limited, it waits as long as the API asks and then tries again, up to
max_retries times (3 by default). If your app key has custom or unlimited limits, pass
rate_limit="none" to turn this off, or a number of seconds to wait between requests.
The game also has its own limit of 15 commands every 10 seconds per server. Go over it and the
extra commands fail with RATE_LIMITED.
Errors¶
from oxrpy import (
OxfordAPIError, # all the errors below are based on this: .status, .code, .message, .body
AuthenticationError, # wrong key, no API package, or a bad or suspended app key
BadRequestError, # a typo in a section name; .valid_parameters lists the right ones
NotFoundError, # e.g. a command ID that doesn't exist (results are kept for 7 days)
RateLimitError, # still rate limited after retrying; .retry_after says how long to wait
ServerOfflineError, # you sent a command while the server was offline
CommandFailedError, # from run_command(..., check=True); .result has the details
)
Reading data from an offline server doesn't raise an error. data.online is False, the live
sections are None, and the logs, bans, staff and settings still work.
API status¶
Want to know if the API itself is up?