aiolichess
Async Python client for the Lichess REST API.
Installation
pip install aiolichess
Quick Start
import asyncio
from aiolichess import AioLichess
async def main():
client = AioLichess()
user = await client.get_all(token="your_pat_here")
print(user.username)
print(user.perfs["blitz"].rating)
print(user.count.win)
await client.close()
asyncio.run(main())
With an external session
import aiohttp
from aiolichess import AioLichess
async with aiohttp.ClientSession() as session:
client = AioLichess(session=session)
user = await client.get_all(token="your_pat_here")
API Reference
AioLichess(session=None)
The main client class.
| Parameter | Type | Description |
|---|---|---|
session |
aiohttp.ClientSession | None |
Optional external session. If not provided, one is created internally. |
await client.get_all(token)
Fetches all account information for the authenticated user via /api/account.
| Parameter | Type | Description |
|---|---|---|
token |
str |
Lichess personal API token |
Returns a LichessUser object.
await client.get_user_id(token)
Fetches only the user ID of the authenticated user.
| Parameter | Type | Description |
|---|---|---|
token |
str |
Lichess personal API token |
Returns a str.
user_id = await client.get_user_id(token="your_pat_here")
print(user_id) # "drnykterstien"
await client.get_username(token)
Fetches only the username of the authenticated user.
| Parameter | Type | Description |
|---|---|---|
token |
str |
Lichess personal API token |
Returns a str.
username = await client.get_username(token="your_pat_here")
print(username) # "DrNykterstein"
await client.get_statistics(token)
Fetches rating and game count statistics across all formats.
| Parameter | Type | Description |
|---|---|---|
token |
str |
Lichess personal API token |
Returns a LichessStatistics object.
stats = await client.get_statistics(token="your_pat_here")
print(stats.blitz_rating)
print(stats.rapid_games)
print(stats.puzzle_rating)
await client.close()
Closes the session. Only closes if the session was created internally — never closes an externally provided session.
Models
LichessUser
| Field | Type |
|---|---|
id |
str |
username |
str |
url |
str |
created_at |
int |
seen_at |
int |
play_time |
int |
perfs |
dict[str, LichessPerf] |
profile |
LichessProfile | None |
count |
LichessCount | None |
LichessPerf
| Field | Type |
|---|---|
rating |
int |
games |
int |
rd |
int |
prog |
int |
prov |
bool |
LichessProfile
| Field | Type |
|---|---|
flag |
str | None |
location |
str | None |
bio |
str | None |
fide_rating |
int | None |
uscf_rating |
int | None |
ecf_rating |
int | None |
LichessCount
| Field | Type |
|---|---|
all |
int |
rated |
int |
win |
int |
loss |
int |
draw |
int |
LichessStatistics
Rating and games-played counts across every perf exposed by /api/account.
Any perf the user has never played is reported as None.
| Field | Type |
|---|---|
ultra_bullet_rating |
int | None |
ultra_bullet_games |
int | None |
bullet_rating |
int | None |
bullet_games |
int | None |
blitz_rating |
int | None |
blitz_games |
int | None |
rapid_rating |
int | None |
rapid_games |
int | None |
classical_rating |
int | None |
classical_games |
int | None |
correspondence_rating |
int | None |
correspondence_games |
int | None |
chess960_rating |
int | None |
chess960_games |
int | None |
crazyhouse_rating |
int | None |
crazyhouse_games |
int | None |
antichess_rating |
int | None |
antichess_games |
int | None |
atomic_rating |
int | None |
atomic_games |
int | None |
horde_rating |
int | None |
horde_games |
int | None |
king_of_the_hill_rating |
int | None |
king_of_the_hill_games |
int | None |
racing_kings_rating |
int | None |
racing_kings_games |
int | None |
three_check_rating |
int | None |
three_check_games |
int | None |
puzzle_rating |
int | None |
puzzle_games |
int | None |
Exceptions
| Exception | Raised on |
|---|---|
AioLichessError |
Base exception, catch-all |
AuthError |
401 — invalid or missing token |
RateLimitError |
429 — rate limit hit, wait 60s |
LichessServerError |
5xx — Lichess server error |
License
GPL-3.0
Metadata
Release files for aiolichess 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiolichess-1.3.0.tar.gz | 31.2 kB | With provenance | Details for aiolichess-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiolichess-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for aiolichess-1.3.0-py3-none-any.whl |
Total release size: 61.8 kB
Release files / aiolichess-1.3.0.tar.gz
| Download URL | aiolichess-1.3.0.tar.gz |
|---|---|
| Size | 31.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f009a9dc31d040002ac8408212a2eea0dcd0c3b8bee8fb023f701e87541b6f6
|
|
BLAKE2b-256 checksum How to use checksums |
4862a32f1aca0bb2298c3400759e9a0ca9dea2bb1007f89d5e029f431372d7c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logRelease files / aiolichess-1.3.0-py3-none-any.whl
| Download URL | aiolichess-1.3.0-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6c838d487f6a65d89672d767fe190f165c86c76576c326f06133867ae60f5a8
|
|
BLAKE2b-256 checksum How to use checksums |
c332735d9dd103f65962eab0b19bc9330c62c11e11980a1400d6afc55f0cc16a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logSecurity for aiolichess 1.3.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for aiolichess-1.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 24, 2026.
Transparency logA 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.