Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A client for the lichess.org API

Project description

This is a client library for the lichess.org API. It is designed to be:

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'])
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:

>>> 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-lichess, version 0.9
Filename, size File type Python version Upload date Hashes
Filename, size python_lichess-0.9-py3-none-any.whl (21.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size python-lichess-0.9.tar.gz (7.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page