Skip to main content

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

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

lichesspy-6.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

lichesspy-6.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file lichesspy-6.0.1.tar.gz.

File metadata

  • Download URL: lichesspy-6.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for lichesspy-6.0.1.tar.gz
Algorithm Hash digest
SHA256 c9ed9ee4ce04e313f1d83a5b9c667233d1300ce8c6f7b519624356dbed4a32b6
MD5 a3aa3501400c2c31585dcf4194153e3f
BLAKE2b-256 3401fc09713cb1d441f47a1cc3c793ba87cf50d40b4e5c855a321584c14d4cc5

See more details on using hashes here.

File details

Details for the file lichesspy-6.0.1-py3-none-any.whl.

File metadata

  • Download URL: lichesspy-6.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for lichesspy-6.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a17f16648628a33be8f3474e5384a0b7bc406fac3ae7fe8ea190cd19aae8d73c
MD5 097092453b8df6938c709c282fe46550
BLAKE2b-256 b0c00615bb743f332cff694bdb98c60932bd0304387659daf263e5eff939a690

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