Python wrapper for lichess
Project description
A client for the lichess.org API
This is a client library for the Lichess API. It is designed to be:
-
Easy to use
-
Customizable when you need it
-
Adaptable to API changes
Getting a user's rating:
>>> import lichesspy.api
>>>
>>> user = lichesspy.api.user('thibault')
>>> print(user['perfs']['blitz']['rating'])
1617
Checking who's online and playing:
>>> import lichesspy.api
>>>
>>> users = list(lichesspy.api.users_status(['thibault', 'cyanfish']))
>>> online = [u['id'] for u in users if u.get('online', False)]
>>> playing = [u['id'] for u in users if u.get('playing', False)]
>>> print(online, playing)
['thibault', 'cyanfish'] ['cyanfish']
Saving a PGN of a user's last 200 games:
>>> import lichesspy.api
>>> from lichesspy.format import SINGLE_PGN
>>>
>>> pgn = lichesspy.api.user_games('thibault', max=200, format=SINGLE_PGN)
>>> with open('last200.pgn', 'w') as f:
>>> f.write(pgn)
Integrating with python-chess:
>>> import lichesspy.api
>>> from lichesspy.format import PYCHESS
>>>
>>> game = lichesspy.api.game('Qa7FJNk2', format=PYCHESS)
>>> print(game.end().board())
. . k . R b r .
. p p r . N p .
p . . . . . . p
. . . . . . . .
. . . p . . . .
P . . P . . . P
. P P . . P P .
. . K R . . . .
Installing
pip install lichesspy
Farewell
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lichesspy-6.0.5.dev0.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file lichesspy-6.0.5.dev0.tar.gz
.
File metadata
- Download URL: lichesspy-6.0.5.dev0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b3f0715f469f4b9e78f096c04fadd4069fd7cca0405e08f54831e2ea9788683 |
|
MD5 | 83470b5cef0728c64d3e5ece07a26740 |
|
BLAKE2b-256 | 949b9e71094587cfcee9fa55bcea86163f67c55e6ead1e89edb8da0be31c05d5 |
File details
Details for the file lichesspy-6.0.5.dev0-py3-none-any.whl
.
File metadata
- Download URL: lichesspy-6.0.5.dev0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc99faf9614f6a3a400d32050dc5b75ec231622497cb511a6691db9af49a4f10 |
|
MD5 | 42ccc5fc6ac9f6fed750cf99aedec2e2 |
|
BLAKE2b-256 | 6f1bb170593e191cd3e529755f9f9c663cd1417ba8c1ebf03c601a8d7a005e9d |