Python library extending the Chess.com public API (e.g. games by opening)
Project description
chesscompy
A small Python library that extends the Chess.com public API. It starts by adding games by opening: fetch a player's games and filter by ECO code or opening name (e.g. Pirc Defense, Caro-Kann).
The official API only supports:
GET /player/{username}/games/{YYYY}/{MM}— games in a given month.
There is no server-side filter by opening, so chesscompy fetches games (by month) and filters client-side using each game's eco field (Chess.com opening URL) and PGN [ECO "B07"] tag.
Install
pip install chesscompy
Development
For an editable install with test tools:
git clone https://github.com/cdewitt02/chesscompy.git
cd chesscompy
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS (.venv\Scripts\activate on Windows)
pip install -e ".[dev]"
Run tests:
pytest tests/ -v
Usage
from chesscompy import get_games, get_games_by_opening
# All games for a player in a month (direct API)
games = get_games("cdew4", 2026, 1)
# Games in that month that match an opening (client-side filter)
pirc_games = get_games_by_opening("cdew4", "B07", 2026, 1) # ECO code
caro_games = get_games_by_opening("cdew4", "Caro-Kann", 2026, 1) # name substring
# All games in a year matching an opening (12 API calls, then filter)
caro_in_year = get_games_by_opening("cdew4", "Caro-Kann", 2026)
Each game is a dict with the same shape as the API: url, pgn, white, black, eco, time_control, fen, etc.
Project layout
chesscompy/— main package_client.py— HTTP GET and URL helpers for api.chess.comgames.py—get_games(username, year, month),get_games_by_opening(...)__init__.py— re-exports public API
pyproject.toml— metadata, dependencies, tool configresponses/— sample API responses (e.g. for tests)
License
MIT (see LICENSE).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chesscompy-0.1.0.tar.gz.
File metadata
- Download URL: chesscompy-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3293330ada5906a516bab8a4a0791f26d1751b3c44720eaa347b4706653a5e53
|
|
| MD5 |
6370dc97f7a9377631983c91fe1ae1ef
|
|
| BLAKE2b-256 |
bd61ae961aa1c789c4ef8e9ae98ad9ed7520977ebda6c50ae6424c540391f3c4
|
File details
Details for the file chesscompy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chesscompy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9c5c631861b17f216dbf4075fdeb8a8e1e9f137321f6ffe88337e9dc481a8f7
|
|
| MD5 |
e2819d4b815c9632fcb10f07af209850
|
|
| BLAKE2b-256 |
b3ccd7b64fe9a32698ccec10fa382c76b3c408792e810ffdf5c3c81b2357d5c9
|