Skip to main content

Export your chess.com games using the public API

Project description

chessdotcom_export

Export your chess.com games using the public API. Published-Data API Docs

Installation

Requires python3.6+

To install with pip, run:

pip install chessdotcom_export

Usage

export

chessdotcom_export export --help
Usage: chessdotcom_export export [OPTIONS] USERNAME

  Export your chess games

Options:
  --help  Show this message and exit.

The only required argument is your username, the API serves public data and has no serial rate limit.

inspect

Usage: chessdotcom_export inspect [OPTIONS]

  Parse an exported JSON file and interact with it

Options:
  -f, --from-file PATH  Exported file to read from  [required]
  --help                Show this message and exit.

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

$ chessdotcom_export 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
$ chessdotcom_export inspect -f 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

Library Usage

You can also run the commands from python:

In [1]: import chessdotcom_export

In [2]: games = list(chessdotcom_export.get_player_games("seanbreckenridge"))
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

In [3]: games[0].fen
Out[3]: 'r3k2r/5ppp/1Qp5/p3p2q/K3P3/4BP1N/1PP3PP/R4B1R b kq -'

In [4]: export = chessdotcom_export.from_export("data.json")

In [5]: export[0].fen
Out[5]: 'r3k2r/5ppp/1Qp5/p3p2q/K3P3/4BP1N/1PP3PP/R4B1R b kq -'

Tests

git clone 'https://github.com/seanbreckenridge/chessdotcom_export'
cd ./chessdotcom_export
pip install '.[testing]'
mypy ./chessdotcom_export

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

chessdotcom_export-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chessdotcom_export-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file chessdotcom_export-0.1.0.tar.gz.

File metadata

  • Download URL: chessdotcom_export-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.2

File hashes

Hashes for chessdotcom_export-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1775883e5e2dd02745644ec09a5482bd4d8d29cf8771ce0cea7d54aaffd665cf
MD5 0af380ad2e6271db678bb0186d337a3d
BLAKE2b-256 035152e6cb1074f162bfbd8e93297ae701c3ac87e7650bd07fcca34d0b298d92

See more details on using hashes here.

File details

Details for the file chessdotcom_export-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chessdotcom_export-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.2

File hashes

Hashes for chessdotcom_export-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5918153ad5c45e90b382f72c3eb1c16fe15e44f497f679c0711f0e2ca7e3dfee
MD5 e246e23e52a86a1b8e38fb37a778efad
BLAKE2b-256 238c09c20ff23fe462a9ed31cd2385343e50659225c3124d748f9b48bb97fe7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page