Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyanfish/python-lichess
Python client for the lichess.org API
https://github.com/cyanfish/python-lichess
Last synced: 3 months ago
JSON representation
Python client for the lichess.org API
- Host: GitHub
- URL: https://github.com/cyanfish/python-lichess
- Owner: cyanfish
- License: gpl-3.0
- Created: 2018-01-27T19:42:01.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T21:33:57.000Z (over 1 year ago)
- Last Synced: 2024-07-15T10:21:16.183Z (4 months ago)
- Language: Python
- Homepage:
- Size: 81.1 KB
- Stars: 53
- Watchers: 5
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
python-lichess: a client for the lichess.org API
================================================
This is a client library for the `lichess.org `_ `API `_. It is designed to be:* Easy to use
* Customizable when you need it
* Adaptable to API changes
* Easy to `integrate `_ with `python-chess `_
Have a look at some short examples. For more, check out the `full documentation `_.
Getting a user's rating:
>>> import lichess.api
>>>
>>> user = lichess.api.user('thibault')
>>> print(user['perfs']['blitz']['rating'])
1617Checking who's online and playing:
>>> import lichess.api
>>>
>>> users = list(lichess.api.users_status(['thibault', 'cyanfish']))
>>> online = [u['id'] for u in users if u['online']]
>>> playing = [u['id'] for u in users if u['playing']]
>>> print(online, playing)
['thibault', 'cyanfish'] ['cyanfish']Saving a PGN of a user's last 200 games:
>>> import lichess.api
>>> from lichess.format import SINGLE_PGN
>>>
>>> pgn = lichess.api.user_games('thibault', max=200, format=SINGLE_PGN)
>>> with open('last200.pgn', 'w') as f:
>>> f.write(pgn)Integrating with `python-chess `_:
>>> import lichess.api
>>> from lichess.format import PYCHESS
>>>
>>> game = lichess.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 python-lichess