Welcome to async_lichess_sdk’s documentation!¶
This package is meant to be an unofficial Python API Client for lichees.org. For information about the API please refer to https://lichess.org/api Every API endpoint uses async Python methods (asyncio).
Requirements¶
Installation¶
You can just install me from a test PyPi
pip install --index-url https://test.pypi.org/simple/ async_lichess_sdk
or official PyPi
pip install async_lichess_sdk
Available Modules / Endpoints¶
APIClient¶
-
class
lichess_client.clients.client.
APIClient
(token: str, loop=None)¶ ASYNC APIClient class for handling secure connections with Lichees API via token usage.
- token: str, required
String with token provided from Lichees.org account site.
- loop: asyncio event loop, optional
Asyncio event loop for async mode operations
Account¶
-
class
lichess_client.endpoints.account.
Account
(client: BaseClient)¶ Class for Account API Endpoint
-
async
get_my_email_address
() → Response¶ Read the email address of the logged in user.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.account.get_my_email_address()
-
async
get_my_kid_mode_status
() → Response¶ Read the kid mode status of the logged in user.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.account.get_my_kid_mode_status()
-
async
get_my_preferences
() → Response¶ Read the preferences of the logged in user.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.account.get_my_preferences()
-
async
get_my_profile
() → Response¶ Public information about the logged in user.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.account.get_my_profile()
-
async
set_my_kid_mode_status
(*, turned_on: bool) → Response¶ Set the kid mode status of the logged in user.
- turned_on: bool, required
The indicator to turn on or turn off the kid mode.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.account.set_my_kid_mode_status()()
-
async
Boards¶
-
class
lichess_client.endpoints.boards.
Boards
(client: BaseClient)¶ Class for Boards API Endpoint
-
async
abort_game
(game_id: str) → Response¶ Abort a game being played with the Board API.
- game_id: str, required
ID of the current playing game.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.boards.abort_game(game_id='5IrD6Gzz')
-
async
create_a_seek
(time: int, increment: int, variant: VariantTypes = <VariantTypes.STANDARD: 'standard'>, color: ColorType = <ColorType.RANDOM: 'random'>, rated: bool = False, rating_range: List[int] = None) → Response¶ Create a public seek, to start a game with a random player.
- rated: bool, optional
Whether the game is rated and impacts players ratings.
- time: int, required
Clock initial time in minutes.
- increment: int, required
Clock increment in seconds.
- variant: VariantTypes, optional
- Enum: “standard” “chess960” “crazyhouse” “antichess” “atomic” “horde” “kingOfTheHill”
“racingKings” “threeCheck” The variant of the game.
- color: ColorType, optional
- Enum: “random” “white” “black”
The color to play. Better left empty to automatically get 50% white
- rating_range: List[int, int], optional
The rating range of potential opponents. Better left empty. Example: [1500, 1800]
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.boards.create_a_seek(time=10, increment=0)
-
async
handle_draw
(game_id: str, accept: bool = True) → Response¶ Create/accept/decline draw offers.
- game_id: str, required
ID of the current playing game.
- accept: bool, optional
True: Offer a draw, or accept the opponent’s draw offer. False: Decline a draw offer from the opponent.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.boards.handle_draw(game_id='5IrD6Gzz', accept=True)
-
async
make_move
(game_id: str, move: str, draw: bool = False) → Response¶ Make a move in a game being played with the Board API. The move can also contain a draw offer/agreement.
- game_id: str, required
ID of the current playing game.
- move: str, required
Move in UCI format.
- draw: bool, optional
Offer or accept a draw.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.boards.make_move(game_id='5IrD6Gzz', move='e2e4')
-
async
resign_game
(game_id: str) → Response¶ Resign a game being played with the Board API.
- game_id: str, required
ID of the current playing game.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.boards.resign_game(game_id='5IrD6Gzz')
-
stream_game_state
(game_id: str) → Response¶ Stream the state of a game being played with the Board API
- game_id: str, required
ID of the current playing game.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> async for response in client.boards.stream_game_state(game_id='5IrD6Gzz'): >>> print(response)
-
stream_incoming_events
() → Response¶ Stream the events reaching a lichess user in real time.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> async for response in client.boards.stream_incoming_events(): >>> print(response)
-
async
write_in_chat
(game_id: str, message: str, room: lichess_client.utils.enums.RoomTypes = <RoomTypes.PLAYER: 'player'>)¶ Post a message to the player or spectator chat, in a game being played with the Board API.
- game_id: str, required
ID of the current playing game.
- room: RoomTypes, optional
Room where to post a message [player, spectator].
- message: str, required
User message to post.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response_1 = await client.boards.write_in_chat(game_id='5IrD6Gzz', message="Hello!") >>> response_2 = await client.boards.write_in_chat(game_id='5IrD6Gzz', message="Hi all!", room=RoomTypes.SPECTATOR)
-
async
Bots¶
-
class
lichess_client.endpoints.bots.
Bots
(client: BaseClient)¶ Class for Bots API Endpoint
-
async
stream_incoming_events
() → Response¶ Stream the events reaching a lichess user in real time.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.bots.get_my_profile()
-
async
Broadcast¶
-
class
lichess_client.endpoints.broadcast.
Broadcast
(client: BaseClient)¶ Class for Broadcast API Endpoint
-
async
create
(name: str, description: str, source_url: str = None, markdown: str = None, credit: str = None, start_time: int = None) → Response¶ Create a new broadcast to relay external games.
- name: str, required
Name of the broadcast. Length must be between 3 and 80 characters.
- description: str, required
Short description of the broadcast. Length must be between 3 and 400 characters.
- source_url: str, optional
URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. Example: http://myserver.org/myevent/round-10/games.pgn If the syncUrl is missing, then the broadcast needs to be fed by pushing PGN to it.
- markdown: str, optional
Optional long description of the broadcast. Markdown is supported. Length must be less than 20,000 characters.
- credit: str, optional
Optional short text to give credit to the source provider.
- start_time: int, optional
Timestamp of broadcast start. Leave empty to manually start the broadcast. Example: 1356998400070
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.broadcast.create(name="my broadcast", description="this is my broadcast...")
-
async
get
(broadcast_id: str) → Response¶ Get information about a broadcast that you created. You will need it if you want to update that broadcast.
broadcast_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.broadcast.get(broadcast_id="wje07860")
-
async
push_pgn
(broadcast_id: str, games: str) → Response¶ Update your broadcast with new PGN. Only for broadcast without a source URL.
broadcast_id: str, required
- games: str, required
The PGN. It can contain up to 64 games, separated by a double new line.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.broadcast.push_pgn(broadcast_id="wje07860", games="...")
-
async
update
(broadcast_id: str, name: str, description: str, source_url: str = None, markdown: str = None, credit: str = None, start_time: int = None) → Response¶ Update information about a broadcast that you created. This endpoint accepts the same form data as the web form. All fields must be populated with data. Missing fields will override the broadcast with empty data. For instance, if you omit startDate, then any pre-existing start date will be removed.
broadcast_id: str, required
- name: str, required
Name of the broadcast. Length must be between 3 and 80 characters.
- description: str, required
Short description of the broadcast. Length must be between 3 and 400 characters.
- source_url: str, optional
URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. Example: http://myserver.org/myevent/round-10/games.pgn If the syncUrl is missing, then the broadcast needs to be fed by pushing PGN to it.
- markdown: str, optional
Optional long description of the broadcast. Markdown is supported. Length must be less than 20,000 characters.
- credit: str, optional
Optional short text to give credit to the source provider.
- start_time: int, optional
Timestamp of broadcast start. Leave empty to manually start the broadcast. Example: 1356998400070
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.broadcast.update(broadcast_id="wje07860", name="my broadcast", description="this is my updated broadcast...")
-
async
Challenges¶
-
class
lichess_client.endpoints.challenges.
Challenges
(client: BaseClient)¶ Class for Challenges API Endpoint
-
async
accept
(challenge_id: str) → Response¶ - Accept an incoming challenge.
You should receive a gameStart event on the incoming events stream.
- challenge_id: str, required
ID of the challenge to accept, further game_id will be the same as this challenge_id.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.challenges.accept(challenge_id="5IrD6Gzz")
-
async
create
(username: str, time_limit: int = None, time_increment: int = None, rated: bool = False, days: int = None, color: ColorType = <ColorType.RANDOM: 'random'>, variant: VariantTypes = <VariantTypes.STANDARD: 'standard'>, position: str = None) → Response¶ - Challenge someone to play. The targeted player can choose to accept or decline.
If the challenge is accepted, you will be notified on the event stream that a new game has started. The game ID will be the same as the challenge ID.
username: str, required
- time_limit: int, optional
[1..10800] Clock initial time in seconds. If empty, a correspondence game is created.
- time_increment: int, optional
[0..60] Clock increment in seconds. If empty, a correspondence game is created.
- rated: bool: optional
Game is rated and impacts players ratings
- days: int, optional
[1..15] Days per move, for correspondence games. Time settings must be omitted.
- color: ColorType, optional
Enum: “random” “white” “black” Which color you get to play, default: “random”.
- variant: VariantTypes, optional
Default: “standard” Enum: “standard” “chess960” “crazyhouse” “antichess” “atomic” “horde” “kingOfTheHill”
“racingKings” “threeCheck”
The variant of the game
- position: str, optional
Default: “rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1” Custom initial position (in FEN). Variant must be standard, and the game cannot be rated.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.challenges.create(username="amasend")
-
async
decline
(challenge_id: str) → Response¶ Decline an incoming challenge.
- challenge_id: str, required
ID of the challenge to decline.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.challenges.decline(challenge_id="5IrD6Gzz")
-
async
stream_incoming_events
()¶ Stream the events reaching a lichess user in real time. This method is implemented in “boards” endpoint.
lichess_client.APIClient.boards.stream_incoming_events()
-
async
Games¶
-
class
lichess_client.endpoints.games.
Games
(client: BaseClient)¶ Class for Games API Endpoint
-
async
export_games_by_ids
(game_ids: List[str]) → lichess_client.helpers.response_helpers.Response¶ Download games by IDs.
Games are sorted by reverse chronological order (most recent first)
The method is POST so a longer list of IDs can be sent in the request body. At most 300 IDs can be submitted.
- game_ids: List[str], required
IDs of the games.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.export_games_by_ids(game_ids=['q7zvsdUF', 'ILwozzRZ'])
-
async
export_games_of_a_user
(username: str, since: int = None, until: int = None, limit: int = None, vs: str = None, rated: bool = None, variant: Union[VariantTypes, List[VariantTypes]] = None, color: Optional[lichess_client.utils.enums.ColorType] = None, analysed: bool = None, ongoing: bool = False) → lichess_client.helpers.response_helpers.Response¶ Download all games of any user in PGN format. Games are sorted by reverse chronological order (most recent first) We recommend streaming the response, for it can be very long. https://lichess.org/@/german11 for instance has more than 320,000 games. The game stream is throttled, depending on who is making the request:
Anonymous request: 15 games per second OAuth2 authenticated request: 25 games per second Authenticated, downloading your own games: 50 games per second
- username: str, required
Name of the user.
- since: int, optional
Default: “Account creation date” Download games played since this timestamp.
- until: int, optional
Default: “Now” Download games played until this timestamp.
- limit: int, optional
Default: None How many games to download. Leave empty to download all games.
- vs: str, optional
[Filter] Only games played against this opponent
- rated: bool, optional
Default: None
[Filter] Only rated (true) or casual (false) games
- variant: Union[VariantTypes, List[VariantTypes]], optional
Default: None [Filter] Only games in these speeds or variants. Multiple variants can be specified in a list.
- color: ColorType, optional
Default: None [Filter] Only games played as this color.
- analysed: bool, optional
[Filter] Only games with or without a computer analysis available.
- ongoing: bool, optional
Default: false [Filter] Also include ongoing games
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.export_games_of_a_user(username='amasend') # TODO: add more examples
-
async
export_one_game
(game_id: str) → lichess_client.helpers.response_helpers.Response¶ Download one game. Only finished games can be downloaded.
- game_id: str, required
ID of the game.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.export_one_game(game_id='q7zvsdUF') # TODO: add more examples
-
async
get_current_tv_games
() → lichess_client.helpers.response_helpers.Response¶ Get basic info about the best games being played for each speed and variant, but also computer games and bot games.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_current_tv_games()
-
async
get_ongoing_games
(limit: int = 9) → lichess_client.helpers.response_helpers.Response¶ Get the ongoing games of the current user. Real-time and correspondence games are included. The most urgent games are listed first.
- limit: int, optional
Number of games to fetch, default is 9.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response_1 = client.users.get_ongoing_games(limit=10) >>> response_2 = client.users.get_ongoing_games()
-
async
stream_current_games
(users: List[str]) → lichess_client.helpers.response_helpers.Response¶ Stream the games played between a list of users, in real time. Only games where both players are part of the list are included. Maximum number of users: 300. The method is POST so a longer list of IDs can be sent in the request body.
- users: List[str], required
User names.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.stream_current_games(users=['amasend', 'lovlas', 'chess-network'])
-
async
Messaging¶
-
class
lichess_client.endpoints.messaging.
Messaging
(client: BaseClient)¶ Class for Messaging API Endpoint
-
async
send
(username: str, text: str) → Response¶ Send a private message to another player.
username: str, required
text: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.messaging.send()
-
async
Relations¶
-
class
lichess_client.endpoints.relations.
Relations
(client: BaseClient)¶ Class for Relations API Endpoint
-
async
get_users_followed_by_a_user
(username: str) → Response¶ - Fetching all users followed by current user.
This is a streaming endpoint.
username: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_users_followed_by_a_user(username='amasend')
-
async
get_users_who_follow_a_user
(username: str) → Response¶ - Fetching all users who follow this user.
This is a streaming endpoint.
username: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_users_who_follow_a_user(username='amasend')
-
async
Simulations¶
-
class
lichess_client.endpoints.simulations.
Simulations
(client: BaseClient)¶ Class for Simulations API Endpoint
-
async
get_current
() → Response¶ Get recently finished, ongoing, and upcoming simuls.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.simulations.get_current()
-
async
Studies¶
-
class
lichess_client.endpoints.studies.
Studies
(client: BaseClient)¶ Class for Studies API Endpoint
-
async
export_all_chapters
(study_id: str) → Response¶ Download all chapters of a study in PGN format.
study_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.studies.export_all_chapters(study_id="...")
-
async
export_chapter
(study_id: str, chapter_id: str) → Response¶ Download one study chapter in PGN format.
study_id: str, required
chapter_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.studies.export_chapter(study_id="...", chapter_id='...')
-
async
Teams¶
-
class
lichess_client.endpoints.teams.
Teams
(client: BaseClient)¶ Class for Teams API Endpoint
-
async
get_members_of_a_team
() → None¶ Not implemented
client.users.get_members_of_a_team(…)
-
async
join_a_team
(team_id: str) → lichess_client.helpers.response_helpers.Response¶ Join a team. If the team join policy requires a confirmation, and the team owner is not the oAuth app owner, then the call fails with 403 Forbidden.
team_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.join_a_team(team_id = 'some_team')
-
async
kick_a_user_from_your_team
(team_id: str, user_id: str) → lichess_client.helpers.response_helpers.Response¶ Kick a member out of one of your teams.
team_id: str, required
user_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.kick_a_user_from_your_team(team_id='some_team', user_id='amasend')
-
async
leave_a_team
(team_id: str) → lichess_client.helpers.response_helpers.Response¶ Leave a team.
team_id: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.leave_a_team(team_id = 'some_team')
-
async
Tournaments¶
-
class
lichess_client.endpoints.tournaments.
Tournaments
(client: BaseClient)¶ Class for Tournaments API Endpoint
-
async
create
(clock_time: int, clock_increment: int, minutes: int, name: str = None, wait_minutes: int = 5, start_date: int = None, variant: VariantTypes = <VariantTypes.STANDARD: 'standard'>, rated: bool = True, position: str = None, berserk: bool = True, password: str = None, team_id: str = None, min_rating: int = None, max_rating: int = None, number_of_rated_games: int = None) → Response¶ - Create a public or private tournament to your taste.
This endpoint mirrors the form on https://lichess.org/tournament/new. You can create up to 2 tournaments per day.
name: str, optional
- clock_time: int, required
[0..60] Clock initial time in minutes
- clock_increment: int, required
[0..60] Clock increment in seconds
- minutes: int, required
[0..360] How long the tournament lasts, in minutes.
- wait_minutes: int, optional
Default: 5 How long to wait before starting the tournament, from now, in minutes
- start_date: int, optional
Timestamp to start the tournament at a given date and time. Overrides the waitMinutes setting.
- variant: VariantTypes, optional
Default: “standard” Enum: “standard” “chess960” “crazyhouse” “antichess” “atomic” “horde”
“kingOfTheHill” “racingKings” “threeCheck”
The variant to use in tournament games
- rated: bool, optional
Default: true Games are rated and impact players ratings
- position: str, optional
Default: “rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1” Custom initial position (in FEN) for all games of the tournament. Must be one of
- berserk: bool, optional
Default: true Whether the players can use berserk
- password: str, optional
Make the tournament private, and restrict access with a password
- team_id, str, optional
- Restrict entry to members of a team. The team_id is the last part of a team URL, e.g.
https://lichess.org/team/coders has teamId = coders.
Leave as None to let everyone join the tournament.
- min_rating: int, optional
Minimum rating to join. Leave empty to let everyone join the tournament.
- max_rating: int, optional
Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament.
- number_of_rated_games: int, optional
Minimum number of rated games required to join.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.tournaments.create(clock_time=1, clock_increment=1, minutes=60)
-
async
export_games
(tournament_id: str) → Response¶ Download games of a tournament. Games are sorted by reverse chronological order (most recent first)
- tournament_id: str, required
ID of the tournament to export.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.tournaments.export_games(tournament_id='q7zvsdUF')
-
async
get_current
()¶ Get recently finished, ongoing, and upcoming tournaments.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = await client.tournaments.get_current()
-
async
get_results
(tournament_id: str, limit: int = 10) → Response¶ - Players of a tournament, with their score and performance, sorted by rank (best first).
games of a tournament. Games are sorted by reverse chronological order (most recent first)
- tournament_id: str, required
ID of the tournament to export.
- limit: int, optional
Default: 10 Max number of players to fetch
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.tournaments.get_results(tournament_id='q7zvsdUF')
-
async
get_tournaments_created_by_a_user
(username: str, limit: int = 10) → Response¶ - Get all tournaments created by a given user.
Tournaments are sorted by reverse chronological order of start date (last starting first).
username: str, required
- limit: int, optional
Default: 10 Max number of tournaments to fetch.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.tournaments.get_tournaments_created_by_a_user(username='amasend')
-
async
Users¶
-
class
lichess_client.endpoints.users.
Users
(client: BaseClient)¶ Class for Users API Endpoint
-
async
get_all_top_10
() → Response¶ Get the top 10 players for each speed and variant.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_all_top_10()
-
async
get_live_streamers
() → Response¶ Get basic info about currently streaming users.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_live_streamers()
-
async
get_members_of_a_team
(team_id: str) → Response¶ - Download your puzzle activity in ndjson format.
Puzzle activity is sorted by reverse chronological order (most recent first)
- team_id: str, required
Team ID
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_members_of_a_team(team_id='team')
-
async
get_one_leaderboard
(variant: VariantTypes, limit: int = 10) → Response¶ - Get the leaderboard for a single speed or variant (a.k.a. perfType).
There is no leaderboard for correspondence or puzzles.
- limit: int, optional
How many users to fetch.
variant: VariantTypes, required
Response object with response content.
VariantTypes
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_one_leaderboard(variant=VariantTypes.BLITZ) >>> response_2 = client.users.get_one_leaderboard(variant=VariantTypes.ANTICHESS, limit=100)
-
async
get_rating_history_of_a_user
(username: str) → Response¶ - Read rating history of a user, for all perf types. There is at most one entry per day.
Format of an entry is [year, month, day, rating]. month starts at zero (January).
username: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_rating_history_of_a_user(username='amasend')
-
async
get_real_time_users_status
(users_ids: List[str]) → Response¶ Read the online, playing and streaming flags of several users.
This API is very fast and cheap on lichess side. So you can call it quite often (like once every 5 seconds).
Use it to track players and know when they’re connected on lichess and playing games.
- users_ids: List[str], required
List of the users IDs to fetch information about the status.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_real_time_users_status( >>> users_ids=['amasend', 'aliquantus','chess-network', 'lovlas'])
-
async
get_user_activity
(username: str) → Response¶ Read data to generate the activity feed of a user.
username: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_user_activity(username='amasend')
-
async
get_user_public_data
(username: str) → Response¶ Read public data of a user.
username: str, required
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_user_public_data(username='amasend')
-
async
get_users_by_id
(users_ids: List[str]) → Response¶ - Get several users by their IDs. Users are returned in the order same order as the IDs.
The method is POST so a longer list of IDs can be sent in the request body.
- users_ids: List[str], required
List of the users IDs to fetch information about the status.
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_users_by_id(users_ids=['amasend', 'aliquantus','chess-network', 'lovlas'])
-
async
get_your_puzzle_activity
(limit: int = None) → Response¶ Download your puzzle activity in ndjson format. Puzzle activity is sorted by reverse chronological order (most recent first)
- limit: int, optional
Hom many records to fetch, if None, all records will be fetched (by streaming).
Response object with response content.
>>> from lichess_client import APIClient >>> client = APIClient(token='...') >>> response = client.users.get_your_puzzle_activity() >>> response_2 = client.users.get_your_puzzle_activity(limit=50)
-
async
Helpers¶
-
class
lichess_client.helpers.response_helpers.
Response
(metadata: lichess_client.helpers.response_helpers.ResponseMetadata, entity: lichess_client.helpers.response_helpers.ResponseEntity)¶ The Response class. Used to store every API response in the unified way.
-
class
lichess_client.helpers.response_helpers.
ResponseMetadata
(method: str, url: str, content_type: str, timestamp: bytes)¶ Metadata class for the response object.
-
class
lichess_client.helpers.response_helpers.
ResponseEntity
(code: int, reason: str, status: StatusTypes, content: Union[List[dict], dict, Game])¶ Entity class for the response object.