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.4.dev4.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file lichesspy-6.0.4.dev4.tar.gz
.
File metadata
- Download URL: lichesspy-6.0.4.dev4.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 | 69c65e4de7114fa11db58610b1eacfe75c4511dbc86809ac6f4dd1c765ceef34 |
|
MD5 | 408cbb8b79186acd39440771adca04ed |
|
BLAKE2b-256 | e3b32037dd5487d28e04c01a03c3bd4b2865dc53beb2c5af08802f58723cea73 |
File details
Details for the file lichesspy-6.0.4.dev4-py3-none-any.whl
.
File metadata
- Download URL: lichesspy-6.0.4.dev4-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 | c2c317427bf5148bc808cae0fdedebbf42e6a9d6c519219092c7392c38b814be |
|
MD5 | 1b5caec42c659958ec51338151aa010f |
|
BLAKE2b-256 | d96248f8da107d7c799577275d1d7256066154162efd4f84eb7af7a3882de723 |