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.dev2.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for lichesspy-6.0.4.dev2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91eabd9c20751897c2b39e2f430ee29e351d563c31ae125ae56618c32f7bf2eb |
|
MD5 | fe9afb421def9267cc865b1ccbde6b01 |
|
BLAKE2b-256 | 0a5dcb73b7ff07d9f526b01450dd9ea44208925bc7163695846a65a75c65f89c |