chess-export


Namechess-export JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/seanbreckenridge/chess_export
SummaryExport your chess.com/lichess.org games
upload_time2023-08-28 09:18:10
maintainer
docs_urlNone
authorSean Breckenridge
requires_python
licenseMIT
keywords chess data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # chess_export

[![PyPi version](https://img.shields.io/pypi/v/chess_export.svg)](https://pypi.python.org/pypi/chess_export) [![Python 3.7|3.8|3.9|3.10](https://img.shields.io/pypi/pyversions/chess_export.svg)](https://pypi.python.org/pypi/chess_export) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

Export your (or someone else's) chess.com/lichess.org games using their APIs

- Chess.com requires no authentication, see their [public API docs](https://www.chess.com/news/view/published-data-api)
- Lichess requires you to create a token, you can do so by going [here](https://lichess.org/account/oauth/token/create?description=lichess+export) (this requires no extra scopes)

## Installation

Requires `python3.8+`

To install with pip, run:

    pip install chess-export

## Usage

Each subcommand (`chessdotcom`/`lichess`) has an `export` and `inspect` command -- `export` prints data about your games as JSON, `inspect` reads that dumped info 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
...
```

If you're getting 403 errors, you may have to supply a user agent with your email, see [this forum thread](https://www.chess.com/clubs/forum/view/error-403-in-member-profile)

TO do that, you can pass the `--user-agent-email` flag or set the `CHESSDOTCOM_USER_AGENT_EMAIL` environment variable.

### lichess export

Requires your username and a [token](https://lichess.org/account/oauth/token/create?description=lichess+export) (this requires no extra scopes). The token can be provided with the `--token` flag or by setting the `LICHESS_TOKEN` environment variable.

```
$ chess_export lichess export seanbreckenridge > data.json
Requesting https://lichess.org/api/games/user/seanbreckenridge?pgnInJson=true
```

### Example

The games are described in [`PGN`](https://en.wikipedia.org/wiki/Portable_Game_Notation) (which can be parsed using the [`chess`](https://python-chess.readthedocs.io/en/latest/pgn.html) package)

```
$ 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
```

The information returned by `chess.com`/`lichess` are slightly different, see the [lichess/model.py](chess_export/lichess/model.py) and [chessdotcom/model.py](chess_export/chessdotcom/model.py) files for reference

### Tests

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/seanbreckenridge/chess_export",
    "name": "chess-export",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "chess data",
    "author": "Sean Breckenridge",
    "author_email": "seanbrecke@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f9/93/c217d622d5654dbf5ebab31b107c26268dfbad8ea50b27afd607621e0360/chess_export-0.1.1.tar.gz",
    "platform": null,
    "description": "# chess_export\n\n[![PyPi version](https://img.shields.io/pypi/v/chess_export.svg)](https://pypi.python.org/pypi/chess_export) [![Python 3.7|3.8|3.9|3.10](https://img.shields.io/pypi/pyversions/chess_export.svg)](https://pypi.python.org/pypi/chess_export) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\nExport your (or someone else's) chess.com/lichess.org games using their APIs\n\n- Chess.com requires no authentication, see their [public API docs](https://www.chess.com/news/view/published-data-api)\n- Lichess requires you to create a token, you can do so by going [here](https://lichess.org/account/oauth/token/create?description=lichess+export) (this requires no extra scopes)\n\n## Installation\n\nRequires `python3.8+`\n\nTo install with pip, run:\n\n    pip install chess-export\n\n## Usage\n\nEach subcommand (`chessdotcom`/`lichess`) has an `export` and `inspect` command -- `export` prints data about your games as JSON, `inspect` reads that dumped info so you can use it in the REPL.\n\nThe `inspect` command just accepts the file as the first argument, like `chess_export lichess inspect data.json` or `chess_export chessdotcom inspect data.json`\n\n### chessdotcom export\n\nThe only required argument is your username, the API serves public data and has no serial rate limit\n\n```\n$ chess_export chessdotcom export seanbreckenridge >data.json\nRequesting https://api.chess.com/pub/player/seanbreckenridge/games/archives\nRequesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/01\n...\n```\n\nIf you're getting 403 errors, you may have to supply a user agent with your email, see [this forum thread](https://www.chess.com/clubs/forum/view/error-403-in-member-profile)\n\nTO do that, you can pass the `--user-agent-email` flag or set the `CHESSDOTCOM_USER_AGENT_EMAIL` environment variable.\n\n### lichess export\n\nRequires your username and a [token](https://lichess.org/account/oauth/token/create?description=lichess+export) (this requires no extra scopes). The token can be provided with the `--token` flag or by setting the `LICHESS_TOKEN` environment variable.\n\n```\n$ chess_export lichess export seanbreckenridge > data.json\nRequesting https://lichess.org/api/games/user/seanbreckenridge?pgnInJson=true\n```\n\n### Example\n\nThe games are described in [`PGN`](https://en.wikipedia.org/wiki/Portable_Game_Notation) (which can be parsed using the [`chess`](https://python-chess.readthedocs.io/en/latest/pgn.html) package)\n\n```\n$ chess_export chessdotcom export seanbreckenridge >data.json\nRequesting https://api.chess.com/pub/player/seanbreckenridge/games/archives\nRequesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/01\nRequesting https://api.chess.com/pub/player/seanbreckenridge/games/2021/02\n$ chess_export chessdotcom inspect data.json\n\nIn [1]: import io, chess.pgn\n\nIn [2]: game = chess.pgn.read_game(io.StringIO(games[0].pgn))\n\nIn [3]: for move in game.mainline_moves():\n   ...:     print(move)\n   ...:\ne2e4\ne7e6\nb1c3\nd8f6\nd2d3\nf8c5\nd3d4\nc5d4\nf2f3\n```\n\nThe information returned by `chess.com`/`lichess` are slightly different, see the [lichess/model.py](chess_export/lichess/model.py) and [chessdotcom/model.py](chess_export/chessdotcom/model.py) files for reference\n\n### Tests\n\n```bash\ngit clone 'https://github.com/seanbreckenridge/chess_export'\ncd ./chess_export\npip install '.[testing]'\nmypy ./chess_export\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Export your chess.com/lichess.org games",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/seanbreckenridge/chess_export"
    },
    "split_keywords": [
        "chess",
        "data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32d15f3ee718b3fc6b90b3a43dcf7e48d9d862f35e57332189a56bf49814402d",
                "md5": "0b2ec3b02886b18684bb3bd94f98e04a",
                "sha256": "32c2b4604dbb836ea2d91f1e4b2a24899765b0df04cecb8903939a42b2b9b105"
            },
            "downloads": -1,
            "filename": "chess_export-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b2ec3b02886b18684bb3bd94f98e04a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9399,
            "upload_time": "2023-08-28T09:18:08",
            "upload_time_iso_8601": "2023-08-28T09:18:08.775220Z",
            "url": "https://files.pythonhosted.org/packages/32/d1/5f3ee718b3fc6b90b3a43dcf7e48d9d862f35e57332189a56bf49814402d/chess_export-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f993c217d622d5654dbf5ebab31b107c26268dfbad8ea50b27afd607621e0360",
                "md5": "971058b5a44f10d52a486b4327d9116a",
                "sha256": "f366d8df7e0a7842f13479c8a2ef5cfe4a13f7113394c6f5c7cd9f2dfa32134f"
            },
            "downloads": -1,
            "filename": "chess_export-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "971058b5a44f10d52a486b4327d9116a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8545,
            "upload_time": "2023-08-28T09:18:10",
            "upload_time_iso_8601": "2023-08-28T09:18:10.368329Z",
            "url": "https://files.pythonhosted.org/packages/f9/93/c217d622d5654dbf5ebab31b107c26268dfbad8ea50b27afd607621e0360/chess_export-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-28 09:18:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "seanbreckenridge",
    "github_project": "chess_export",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "chess-export"
}
        
Elapsed time: 0.10448s