Skip to content

AsyncOxfordAPI

Every method of OxfordAPI is here too; you await them.

AsyncOxfordAPI

AsyncOxfordAPI(server_key=None, *, app_key=None, timeout=10, rate_limit='auto', max_retries=3, base_url=BASE_URL, client=None, global_key=None, server_id=None)

Bases: AsyncSignatures, BaseClient

Async client for the Oxford Response private server API. Every method of :class:~oxrpy.OxfordAPI is here too; you await them.

Use it with async with, or call await api.aclose() when you're done.

Parameters:

Name Type Description Default
server_key Optional[str]

Your server's API key (Server Management > External > API Key).

None
app_key Optional[str]

Optional app key (oxa_…), sent alongside the server key.

None
timeout float

Seconds to wait for a response (commands always get at least 15).

10
rate_limit Union[str, float, None]

"auto" (default), "none", or seconds between requests.

'auto'
max_retries int

Retries after a 429, or a network error / 500 on a read.

3
base_url str

Override the API base URL (for testing).

BASE_URL
client Any

Use your own httpx.AsyncClient.

None
global_key Optional[str]

Removed in 2.0; passing it warns and treats it as app_key.

None
server_id Optional[str]

No longer used; passing it warns.

None

run_many async

run_many(commands, *, check=False)

Run any number of commands, in order, as fast as the game allows (batches of 10, staying under 15 every 10 seconds). Same as :meth:OxfordAPI.run_many.

sync_staff async

sync_staff(desired, *, remove_others=False)

Make the staff match desired, sending only the changes. Same as :meth:OxfordAPI.sync_staff.

sync_group async

sync_group(group, members, *, remove_others=True)

Make group contain exactly members, sending only the changes. Same as :meth:OxfordAPI.sync_group.

iter_bans async

iter_bans(page_size=1000)

async for ban in api.iter_bans(): every ban, fetching pages as needed.

wait_for_command async

wait_for_command(command_id, *, timeout=130, interval=2)

Poll :meth:get_command until it's no longer pending (gives up after timeout).

follow

follow(*logs, sections=(), limit=None, cursor=None, save_to=None)

An :class:AsyncLogFollower: async for data, new in api.follow("Events"):

save_to (a file path, or an object with load/save) remembers the position across restarts. See :mod:oxrpy.state.

run_forever async

run_forever(*, sections=(), limit=None, cursor=None, skip_existing=True, save_to=None)

Poll and call the handlers registered with :meth:on until :meth:stop (or the task is cancelled). Handlers can be plain functions or async def. In discord.py, start it from setup_hook with asyncio.create_task(api.run_forever()).

Same behaviour and arguments as :meth:OxfordAPI.run_forever, including save_to.

stop

stop()

Make :meth:run_forever return after the current poll.

AsyncLogFollower

AsyncLogFollower(api, logs=('Events',), *, sections=(), limit=None, cursor=None, save_to=None)

Bases: _FollowerBase

The async version of :class:~oxrpy.LogFollower::

async for data, new in api.follow("Events", "KillLogs"): ...

poll async

poll()

Make one request. Errors are raised, not retried.

iter async

iter(*, retry=True, stop=None, on_error=None)

Poll until stop is set (or forever). With retry=False the first error is raised.