Skip to main content
Logo

lichess: a Python wrapper for the Lichess API

Docs License PyPI GitHub Repo Size GitHub Code Size (bytes) Total Lines of Code

lichess is a Python library for interacting with the Lichess API and can be used to get profile data, game data, and much more.


Installation

You can install lichess on the Terminal (macOS/UNIX) or the Command Prompt (Windows) with:

pip install lichess

Alternatively, you can use Git to clone the repository from GitHub with:

git clone https://github.com/qe/lichess.git
cd lichess
pip install .

Or, if you already have it, upgrade to the latest version with:

pip install lichess -U

Usage

For the full documentation, please check the Lichess Python API Documentation.

Some methods, such as Client.get_email(), require authorization while others, such as Client.get_leaderboard(), do not require it. As a result, if you want to use a method/endpoint that does require authorization, you will need to generate a personal access token on Lichess. If you do so, this will be your API Key.

To determine whether or nor you need to generate a personal access token, check if the endpoint you are interested in using has a OAuth2 badge in the Lichess API Documentation.

Here is an example of using lichess without a personal access token:

import lichess

myclient = lichess.Client()

Here is an example of using lichess with a personal access token:

import lichess

API_KEY = "<YOUR API KEY GOES HERE>"
myclient = lichess.Client(token=API_KEY)

Quick Examples

The following are some examples of popular uses of this package:


Get the profile data of a user

import lichess

myclient = lichess.Client()
user = myclient.get_data("bmartin")

Get the rating history of a user

import lichess

myclient = lichess.Client()
history = myclient.get_rating_history("agadmator")

Get the list of users that are offline, online, and playing

import lichess

myclient = lichess.Client()
users = ["Oliver_Penrose", "bmartin", "ismodes", "penguingim1", "Zhigalko_Sergei"]
data = myclient.get_status(users)

offline = [i['name'] for i in data if 'online' not in i.keys()]
online = [i['name'] for i in data if 'online' in i.keys()]
playing = [i['name'] for i in data if 'playing' in i.keys()]

Download all the games of a user

import lichess

myclient = lichess.Client()
games = myclient.export_by_user("penguingim1")

with open("games.pgn", "w") as f:
    f.write(games)
f.close()

Get the list of all the members of a team

import lichess

API_KEY = "<YOUR API KEY GOES HERE>"
myclient = lichess.Client(token=API_KEY)
members = myclient.get_team_members("vu-chess-club")

Get the list of all the IDs of the puzzles you have failed

import lichess

API_KEY = "<YOUR API KEY GOES HERE>"
myclient = lichess.Client(token=API_KEY)
activity = myclient.get_puzzle_activity()
failed = [i['id'] for i in activity if not i['win']]

For more examples, check the examples directory in the source code.


Metadata

Release files for lichess 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lichess 0.2.8
File Size Uploaded
lichess-0.2.8.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lichess 0.2.8
File Interpreter ABI Platform
lichess-0.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / lichess-0.2.8.tar.gz

Download URL lichess-0.2.8.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2c5d4ad2d18978ee684c5e19368efcffa31b7884066f802859eb1fbeaece527c
BLAKE2b-256 checksum
How to use checksums
3a08469d1700494617deaf13b782acc06cce2e56d911cf44bd7a763d32eb2865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release files / lichess-0.2.8-py3-none-any.whl

Download URL lichess-0.2.8-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07399851efd80a286baaf718d2c2c7e5d3b255d5ec23e699ad7c63b874c30fa9
BLAKE2b-256 checksum
How to use checksums
d7fba818b47517cb56c269e1619fa71f0c9b0046219201cb844741078b1e9aef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.2.8 This release

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page