Skip to main content

aiarena-api

An async Python client for the aiarena.net API, the ladder where StarCraft II bots play each other.

Status: alpha. The API may still change between minor versions.

It does the parts every script against aiarena ends up rewriting:

  • Retries: server errors and dropped connections are retried with backoff; client errors are raised at once. Uploads are sent once, since the server may have stored one it failed to answer for.
  • Paging: list endpoints are read to the end with async for, ordered by id so that pages neither repeat nor skip rows that change while they are read.
  • Pacing: an optional cap on requests per minute, shared by every concurrent caller, which tightens on its own while the server returns errors. aiarena is run by volunteers, so a long job should use it.
  • Bulk history: list_bot_match_participations reads a bot's whole match history in large pages, ordered so that offset paging neither skips nor repeats rows, and shrinks the pages when deep offsets start failing.
  • Types: responses are typed with TypedDicts that mirror aiarena's serializers (aiarena_api.schema).

Install

pip install aiarena-api

The distribution is aiarena-api and the import name is aiarena_api. The bare aiarena name on PyPI belongs to an unrelated project.

Use

Every endpoint needs a token, from your aiarena profile. Pass it as token=, or set AIARENA_API_TOKEN.

import asyncio

from aiarena_api import AiArenaClient


async def main() -> None:
    async with AiArenaClient() as client:
        bot = await client.get_bot(961)
        print(bot["name"], bot["plays_race"]["label"])

        # The bot's last ten games, newest first.
        n = 0
        async for participation in client.list_bot_match_participations(961, newest_first=True, page_size=10):
            print(participation["match"], participation["result"], participation["result_cause"])
            n += 1
            if n == 10:
                break


asyncio.run(main())

For a bot you own you can also upload a new version and download its data and match logs:

from pathlib import Path

async with AiArenaClient() as client:
    await client.update_bot(961, bot_zip=Path("build/MyBot.zip"), wiki_article_content="# MyBot\n...")
    data_zip = await client.download_bot_data(961)
    log_zip = await client.download_match_log(participation_id)

A long job, such as importing a season, should be paced:

async with AiArenaClient(rate_per_minute=10) as client:
    ...

Endpoints without a method of their own are reachable with client.get(path, params), client.paginate(path, params) and client.count(path, params), which take a path relative to https://aiarena.net/api/. An absolute URL is accepted only on the API's own server, because every request carries your token; fetch anything else, such as a replay's signed download URL, with a plain HTTP client.

Develop

uv sync
uv run pytest
uv run ruff check

Releases are made by tagging: the version is read from the latest git tag.

Metadata

Release files for aiarena-api 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiarena-api 0.1.2
File Size Uploaded Provenance
aiarena_api-0.1.2.tar.gz 23.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aiarena-api 0.1.2
File Interpreter ABI Platform
aiarena_api-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / aiarena_api-0.1.2.tar.gz

Download URL aiarena_api-0.1.2.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
69bdf5c66b921cec33bfac9fb66bf07c8d13298e3b696bb0719f507f1205db05
BLAKE2b-256 checksum
How to use checksums
6cd5ae1a089096eda9928ccb565f5e778fea3b5311fbf95cd8293b3419f836e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / aiarena_api-0.1.2-py3-none-any.whl

Download URL aiarena_api-0.1.2-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a93acb6d97b2d36fe1225808ad402a156ee6e6231796f89fb513a115231e96a0
BLAKE2b-256 checksum
How to use checksums
3f94d989281ee8ed3e02792c6b5c9858ab0bbab74bdd9d0b2d37de956129ca14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for aiarena-api 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page