pl
python-lichess
pypi i python-lichess
pl

python-lichess

Python client for the lichess.org API

by Ben Olden-Cooligan

0.10 (see all)License:GPL3
pypi i python-lichess
Readme

python-lichess: a client for the lichess.org API

This is a client library for the lichess.org <https://lichess.org> API <https://lichess.org/api>. It is designed to be:

  • Easy to use

  • Customizable when you need it

  • Adaptable to API changes

  • Easy to integrate <format.html#lichess.format.PYCHESS> with python-chess <https://github.com/niklasf/python-chess>

Have a look at some short examples. For more, check out the full documentation <http://python-lichess.readthedocs.io/>_.

Getting a user's rating:

import lichess.api

user = lichess.api.user('thibault') print(user['perfs']['blitz']['rating']) 1617

Checking 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.get('online')] playing = [u['id'] for u in users if u.get('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 <https://github.com/niklasf/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
VersionTagPublished
0.10
2yrs ago
0.9
4yrs ago
0.8
4yrs ago
0.7
4yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate