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.
  • 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 @ git+https://github.com/maxnus/aiarena-api@v0.1.0"

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.1

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.1
File Size Uploaded Provenance
aiarena_api-0.1.1.tar.gz 22.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 34.8 kB

Release files / aiarena_api-0.1.1.tar.gz

Download URL aiarena_api-0.1.1.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d76e91b625f42c4b7fb8c0521f047f5ea4608f2763e4e87cc0c0871342b0a0b9
BLAKE2b-256 checksum
How to use checksums
c25f93754a4e1b154d73d235b0669a1bbae5a4a19bd2798dcc3ac066d5870b62
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.1-py3-none-any.whl

Download URL aiarena_api-0.1.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ac32ea9a3867b3ebe801ae3bea33b9efe5f340a2063b3679335c26fc7daf448
BLAKE2b-256 checksum
How to use checksums
ea46efe80222cd521ef85684e02b57d701cf9a61483b3e5c4fd2335fa395ac27
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.1

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.1 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