Export your chess.com/lichess.org games
Project description
chess_export
Export your chess.com/lichess.org games using their APIs
- Chess.com requires no authentication, see their public API docs
- Lichess requires you to create a token, you can do so by going here (this requires no extra scopes)
Installation
Requires python3.6+
To install with pip, run:
pip install chess-export
Usage
Each subcommand (chessdotcom
/lichess
) has an export
and inspect
command -- export prints your games as JSON, inspect
reads that dumped JSON file so you can use it in the REPL.
The inspect
command just accepts the file as the first argument, like chess_export lichess inspect data.json
or chess_export chessdotcom inspect data.json
chessdotcom export
The only required argument is your username, the API serves public data and has no serial rate limit
$ chess_export chessdotcom export seanbreckenridge >data.json
Requesting https://api.chess.com/pub/player/seanbreckenridge/games/archives
Requesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/01
...
lichess export
Requires your username and a token (this requires no extra scopes). The token can be provided with the --token
flag or by setting the LICHESS_TOKEN
environment variable.
$ python3 -m chess_export lichess export seanbreckenridge > data.json
Requesting https://lichess.org/api/games/user/seanbreckenridge?pgnInJson=true
Example
The games are described in PGN
(which can be parsed using the chess
package), with the final board state in FEN
, also parseable using chess.Board
$ chess_export chessdotcom export seanbreckenridge >data.json
Requesting https://api.chess.com/pub/player/seanbreckenridge/games/archives
Requesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/01
Requesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/02
$ chess_export chessdotcom inspect data.json
In [1]: import io, chess.pgn
In [2]: game = chess.pgn.read_game(io.StringIO(games[0].pgn))
In [3]: for move in game.mainline_moves():
...: print(move)
...:
e2e4
e7e6
b1c3
d8f6
d2d3
f8c5
d3d4
c5d4
f2f3
Tests
git clone 'https://github.com/seanbreckenridge/chess_export'
cd ./chess_export
pip install '.[testing]'
mypy ./chess_export
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chess_export-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6505d09be32818dd0c5352459002e8bcf7203764060c740c29b3b224547f4010 |
|
MD5 | 7a807413831b9e8861b601d07112c5b6 |
|
BLAKE2b-256 | 19bece42691888208bf08d7d32a64bec16c0a9cdfe57e2f9bcce44d21a887b5a |