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.get('online', False)]
>>> playing = [u['id'] for u in users if u.get('playing', False)]
>>> 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

Farewell

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.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

lichesspy-6.0.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lichesspy-6.0.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for lichesspy-6.0.4.tar.gz
Algorithm Hash digest
SHA256 019c91b67a040da22a1fb9162205fff3e941bc0bcacecd91eb63e6aef3690fee
MD5 a1f75ff0e27ac486174a04cf53bff2eb
BLAKE2b-256 cc06c845d24a09447a8f910e6d6812a0da203c4d566ceccf3ea3214196848cbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lichesspy-6.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for lichesspy-6.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 19c0f60318b032f763381bf3e70f1ea5c64770910d670f7873129746d821a493
MD5 29ac7d0525ff9a53d4390ed2d67d7aff
BLAKE2b-256 e545c21940594144eeb942e128364adb7a8c0fa9b6fcaffd45967121d7f2936c

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