Skip to main content

Python client for the lichess API, forked from rhgrant10/berserk

Project description

This is a downstream branch created to continually maintain berserk. Original repository: https://github.com/rhgrant10/berserk

Available on PyPI Continuous Integration Code Coverage Documentation Status

Python client for the Lichess API.

Install

Make sure berserk is uninstalled before installing

pip install berserk-downstream

Features

  • handles JSON and PGN formats at user’s discretion

  • token auth session

  • easy integration with OAuth2

  • automatically converts time values to datetimes

Usage

You can use any requests.Session-like object as a session, including those from requests_oauth. A simple token session is included, as shown below:

import berserk

session = berserk.TokenSession(API_TOKEN)
client = berserk.Client(session=session)

Most if not all of the API is available:

client.account.get
client.account.get_email
client.account.get_preferences
client.account.get_kid_mode
client.account.set_kid_mode
client.account.upgrade_to_bot

client.users.get_puzzle_activity
client.users.get_realtime_statuses
client.users.get_all_top_10
client.users.get_leaderboard
client.users.get_public_data
client.users.get_activity_feed
client.users.get_by_id
client.users.get_by_team
client.users.get_live_streamers
client.users.get_rating_history
client.users.get_crosstable
client.users.get_user_performance

client.relations.get_users_followed
client.relations.follow
client.relations.unfollow

client.teams.get_members
client.teams.join
client.teams.leave
client.teams.kick_member

client.games.export
client.games.export_ongoing_by_player
client.games.export_by_player
client.games.export_multi
client.games.get_among_players
client.games.stream_games_by_ids
client.games.add_game_ids_to_stream
client.games.get_ongoing
client.games.stream_game_moves
client.games.get_tv_channels

client.challenges.create
client.challenges.create_ai
client.challenges.create_open
client.challenges.create_with_accept
client.challenges.accept
client.challenges.decline

client.board.stream_incoming_events
client.board.seek
client.board.stream_game_state
client.board.make_move
client.board.post_message
client.board.abort_game
client.board.resign_game
client.board.handle_draw_offer
client.board.offer_draw
client.board.accept_draw
client.board.decline_draw
client.board.handle_takeback_offer
client.board.offer_takeback
client.board.accept_takeback
client.board.decline_takeback

client.bots.stream_incoming_events
client.bots.stream_game_state
client.bots.make_move
client.bots.post_message
client.bots.abort_game
client.bots.resign_game
client.bots.accept_challenge
client.bots.decline_challenge

client.tournaments.get
client.tournaments.get_tournament
client.tournaments.create_arena
client.tournaments.create_swiss
client.tournaments.export_arena_games
client.tournaments.export_swiss_games
client.tournaments.arena_by_team
client.tournaments.swiss_by_team
client.tournaments.tournaments_by_user
client.tournaments.stream_results
client.tournaments.stream_by_creator

client.broadcasts.create
client.broadcasts.get
client.broadcasts.update
client.broadcasts.push_pgn_update

client.simuls.get

client.studies.export_chapter
client.studies.export

client.messaging.send

client.oauth.test_tokens

client.tv.get_current_games
client.tv.stream_current_game
client.tv.get_best_ongoing

Details for each function can be found in the full documentation.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.11.0 (2021-03-18)

  • Add Tournaments.create_arena for creating arena tournaments

  • Add Tournaments.create_swiss for creating swiss tournaments

  • Add Tournaments.export_arena_games for exporting arena games

  • Add Tournaments.export_swiss_games for exporting swiss games

  • Add Tournaments.arena_by_team for getting arena tournaments by team

  • Add Tournaments.swiss_by_team for getting swiss tournaments by team

  • Add Tournaments.tournaments_by_user for getting tournaments by user

  • Deprecated Tournaments.create and Tournaments.export_games

  • Uploaded fork to pypi

  • Minor fixes for docstrings

  • Minor updates to README, AUTHORS

0.10.0 (2020-04-26)

  • Add Challenge.create_ai for creating an AI challenge

  • Add Challenge.create_open for creating an open challenge

  • Add Challenge.create_with_accept auto-acceptance of challenges using OAuth token

  • Bugfix for passing initial board positions in FEN for challenges

  • Minor fixes for docstrings

0.9.0 (2020-04-14)

  • Add remaining Board endpoints: seek, handle_draw_offer, offer_draw, accept_draw, and decline_draw

  • Multiple doc updates/fixes

  • Add codecov reporting

0.8.0 (2020-03-08)

  • Add new Board client: stream_incoming_events, stream_game_state, make_move, post_message, abort_game, and resign_game

0.7.0 (2020-01-26)

  • Add simuls

  • Add studies export and export chapter

  • Add tournament results, games export, and list by creator

  • Add user followers, users following, rating history, and puzzle activity

  • Add new Teams client: join, get members, kick member, and leave

  • Updated documentation, including new docs for some useful utils

  • Fixed bugs in Tournaments.export_games

  • Deprecated Users.get_by_team - use Teams.get_members instead

0.6.1 (2020-01-20)

  • Add py37 to the travis build

  • Update development status classifier to 4 - Beta

  • Fix py36 issue preventing successful build

  • Make updates to the Makefile

0.6.0 (2020-01-20)

  • Add logging to the berserk.session module

  • Fix exception message when no cause

  • Fix bug in Broadcasts.push_pgn_update

  • Update documentation and tweak the theme

0.5.0 (2020-01-20)

  • Add ResponseError for 4xx and 5xx responses with status code, reason, and cause

  • Add ApiError for all other request errors

  • Fix test case broken by 0.4.0 release

  • Put all utils code under test

0.4.0 (2020-01-19)

  • Add support for the broadcast endpoints

  • Add a utility for easily converting API objects into update params

  • Fix multiple bugs with the tournament create endpoint

  • Improve the reusability of some conversion utilities

  • Improve many docstrings in the client classes

0.3.2 (2020-01-04)

  • Fix bug where options not passed for challenge creation

  • Convert requirements from pinned to sematically compatible

  • Bump all developer dependencies

  • Use pytest instead of the older py.test

  • Use py37 in tox

0.3.1 (2018-12-23)

  • Convert datetime string in tournament creation response into datetime object

0.3.0 (2018-12-23)

  • Convert all timestamps to datetime in all responses

  • Provide support for challenging other players to a game

0.2.1 (2018-12-08)

  • Bump requests dependency to >-2.20.0 (CVE-2018-18074)

0.2.0 (2018-12-08)

  • Add position and start_date params to Tournament.create

  • Add Position enum

0.1.2 (2018-07-14)

  • Fix an asine bug in the docs

0.1.1 (2018-07-14)

  • Added tests for session and formats modules

  • Fixed mispelled PgnHandler class (!)

  • Fixed issue with trailing whitespace when splitting multiple PGN texts

  • Fixed the usage overview in the README

  • Fixed the versions for travis-ci

  • Made it easier to test the JsonHandler class

  • Salted the bumpversion config to taste

0.1.0 (2018-07-10)

  • First release on PyPI.

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

berserk-downstream-0.11.12.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

berserk_downstream-0.11.12-py2.py3-none-any.whl (26.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file berserk-downstream-0.11.12.tar.gz.

File metadata

  • Download URL: berserk-downstream-0.11.12.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.13

File hashes

Hashes for berserk-downstream-0.11.12.tar.gz
Algorithm Hash digest
SHA256 5181cd42f845d81e81027668094e02ba25b67f0232acc51d57ca894542826a8d
MD5 1ec727dc06771eba153f81dda2ca0093
BLAKE2b-256 72cbec2ac8fec3e56fefd022eefe4b1b937e3b96f97acc9d0b576d146dc65587

See more details on using hashes here.

File details

Details for the file berserk_downstream-0.11.12-py2.py3-none-any.whl.

File metadata

  • Download URL: berserk_downstream-0.11.12-py2.py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.13

File hashes

Hashes for berserk_downstream-0.11.12-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aceda721745bd89d45a4d4ed90f4c61266387880b742871afd195e735457a9d8
MD5 a0f6fc31982b20b228c856e8b0573d34
BLAKE2b-256 2367b103af1c04bdfa25a449973c5f76cdce76ab81044dd736f22361fd0d6c9c

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