Skip to main content

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.

Source Distribution

python-lichess-0.10.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

python_lichess-0.10-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file python-lichess-0.10.tar.gz.

File metadata

  • Download URL: python-lichess-0.10.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.3

File hashes

Hashes for python-lichess-0.10.tar.gz
Algorithm Hash digest
SHA256 6fbd1be99680b66c0628b0aa04b8eb8945218daea38bbd8ac465e852b55407f8
MD5 f5e5467df7c1cdf594f064063f2194ca
BLAKE2b-256 83b8f354192bf2b6b2b939111a53ebc85fe8e305af208e124d0042a7872474a3

See more details on using hashes here.

File details

Details for the file python_lichess-0.10-py3-none-any.whl.

File metadata

  • Download URL: python_lichess-0.10-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/3.6.3

File hashes

Hashes for python_lichess-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 36d1a339f366b835b877df43668177dd4c465897495e59957042ae2f0091a0e3
MD5 04accf2ffeafcbd90e20e8326492f5ee
BLAKE2b-256 18d2518a8c482f0bfcacb2a23801cad17d984303919d95d410336c22807889d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page