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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lichesspy-6.0.4.dev5.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.dev5.tar.gz
Algorithm Hash digest
SHA256 660f273b794851ab52eecffb4d8d3b7fbf9c6648696bbc22d52a2d892dfa9d6c
MD5 168f9513109fbb75d55fc259da5ca58b
BLAKE2b-256 4753252e1fec8b6d072f8d246e018228a18326c07b775f3529cd5c3f4dfb37ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lichesspy-6.0.4.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 06149f314a8e931870baafb3a462f6007df6eeca868dc633e0bbb001b1d536bb
MD5 4af3f797561ce819f5d00ae9e6970e51
BLAKE2b-256 45be8c14bb4909cd8fcf8a80e3b48f85a3e60882d1ec167dedc9d7678641d55c

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