Skip to main content

Async Python client for the Lichess REST API

Project description

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiolichess-1.0.0.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiolichess-1.0.0-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file aiolichess-1.0.0.tar.gz.

File metadata

  • Download URL: aiolichess-1.0.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aiolichess-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e63a259bd89b22cb7819cef7671cf41f4b38171670ca3c6542a8e3069eefe139
MD5 dd0b92ef5903385209291bd197fa290c
BLAKE2b-256 d4378af0680b085dcf6f4102e7c8584e2a1ab237ccc9aa6ee29f9c966c6d5b8d

See more details on using hashes here.

File details

Details for the file aiolichess-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aiolichess-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aiolichess-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18b5a5cda7937893710e327cb1cae59adf2dad84b893fcb4ca358ff352a90375
MD5 cefeec5756c35c7989d48ab32bd236a4
BLAKE2b-256 9f1b4ddc9a38a7696156a3d5d11a542f9ff1db2d33ac62203a93401fe44fcd28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page