Chess.com Python API Docs | dltHub
Build a Chess.com-to-database pipeline in Python using dlt with AI harness support for Claude Code, Cursor, and Codex.
Last updated:
Chess.com’s read-only Published-Data API exposes public player, game, club, tournament, country, puzzle, streamer, and leaderboard data as JSON/JSON-LD. The REST API base URL is https://api.chess.com/pub/. The API is public: there is no API key or token, but every request must send a User-Agent header that identifies your app.
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv add "dlt[hub]" and start loading Chess.com data in under 10 minutes.
What data can I load from Chess.com?
Here are some of the endpoints you can load from Chess.com. Every one is a GET on https://api.chess.com/pub/ and returns a single JSON document, so none of them paginates. A {username} segment is filled from a list of players (see the example below). {YYYY}/{MM} comes from the archive list.
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| players_profiles | player/{username} | GET | A player's public profile (player_id, username, title, followers, joined, last_online). | |
| player_stats | player/{username}/stats | GET | Ratings and win/loss/draw records per time class. | |
| archives | player/{username}/games/archives | GET | archives | One URL per month in which the player has games. |
| games | player/{username}/games/{YYYY}/{MM} | GET | games | All games the player finished in that month (uuid, end_time, time_class, pgn, white, black, …). |
| games_pgn | player/{username}/games/{YYYY}/{MM}/pgn | GET | The same month as one multi-game PGN file (text, not JSON). | |
| current_daily_games | player/{username}/games | GET | games | Daily (correspondence) games in progress. |
| games_to_move | player/{username}/games/to-move | GET | games | Daily games where it is the player's turn. |
| player_clubs | player/{username}/clubs | GET | clubs | Clubs the player belongs to. |
| player_matches | player/{username}/matches | GET | finished | Team matches; also in_progress and registered. |
| player_tournaments | player/{username}/tournaments | GET | finished | Tournaments; also in_progress and registered. |
| club | club/{url-id} | GET | A club's profile. | |
| club_members | club/{url-id}/members | GET | all_time | Members, grouped by activity (weekly, monthly, all_time). |
| club_matches | club/{url-id}/matches | GET | finished | The club's team matches; also in_progress and registered. |
| titled_players | titled/{title} | GET | players | Usernames with a title (GM, IM, WGM, …). |
| country_players | country/{iso}/players | GET | players | Usernames of players registered in a country (ISO 3166 code). |
| country_clubs | country/{iso}/clubs | GET | clubs | Club URLs for a country. |
| tournament | tournament/{url-id} | GET | A tournament's details and rounds. | |
| team_match | match/{id} | GET | A daily team match; match/{id}/{board} for one board. | |
| live_team_match | match/live/{id} | GET | A live team match. | |
| daily_puzzle | puzzle | GET | Today's puzzle; puzzle/random for a random one. | |
| streamers | streamers | GET | streamers | Chess.com streamers. |
| leaderboards | leaderboards | GET | Top players per game type (live_blitz, daily, tactics, …). |
I checked every path above against the live API with a sample value.
How do I authenticate with the Chess.com API?
You don't. The Published-Data API is public and read-only: there is no API key, no OAuth token and no Authorization header, so the pipeline has no auth block and needs no secrets.toml entry.
Chess.com does ask every client to identify itself. Requests with an empty User-Agent, or with the default python-requests/... agent, are rejected with HTTP 403. Put an app name and a contact in the User-Agent header; the pipeline below sends it through client.headers.
Configure the players and the User-Agent in .dlt/config.toml:
[sources.chess_com] players = ["MagnusCarlsen", "Hikaru"] user_agent = "my-dlt-pipeline/1.0 (contact: you@example.com)"
These are configuration values, not secrets. dlt reads the file automatically at runtime. See configuration and secrets in dlt.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv init uv add "dlt[hub]"
1. Install the dlt AI harness:
uv run dlthub ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
uv run dlthub ai toolkit install rest-api-pipeline
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Chess.com API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
uv run python chess_com_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline chess_com_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset chess_com_data The duckdb destination used duckdb:/chess_com.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
uv run dlthub show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads player profiles, the monthly archive list and the games in each archive from the Chess.com API into DuckDB. players is a plain list from .dlt/config.toml (see above). Every Chess.com path is scoped to a username, so the other resources take the username from it. The archive month is the incremental cursor:
from typing import Any, List import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources def _archive_row(url: str) -> dict: # https://api.chess.com/pub/player/{username}/games/{YYYY}/{MM} parts = url.rstrip("/").split("/") return {"url": url, "username": parts[-4], "month": f"{parts[-2]}/{parts[-1]}"} @dlt.source(name="chess_com") def chess_com_source( players: List[str] = dlt.config.value, user_agent: str = dlt.config.value, start_month: str = "2026/01", ) -> Any: @dlt.resource(name="players", selected=False) def players_resource(): yield [{"username": p.lower()} for p in players] config: RESTAPIConfig = { "client": { "base_url": "https://api.chess.com/pub/", # public API: no auth block, but Chess.com rejects requests without a User-Agent "headers": {"User-Agent": user_agent}, # every endpoint returns one JSON document "paginator": "single_page", }, "resource_defaults": {"write_disposition": "replace"}, "resources": [ players_resource, { "name": "players_profiles", "primary_key": "player_id", "endpoint": {"path": "player/{resources.players.username}"}, }, { "name": "archives", "primary_key": "url", "write_disposition": "merge", "endpoint": { "path": "player/{resources.players.username}/games/archives", "data_selector": "archives", "incremental": { "cursor_path": "month", "initial_value": start_month, # re-fetch the last seen month: it may still get new games "primary_key": [], }, }, "processing_steps": [{"map": _archive_row}], }, { "name": "games", "primary_key": "uuid", "write_disposition": "merge", "columns": {"end_time": {"data_type": "timestamp"}}, "endpoint": { # the absolute archive URL from the parent resource "path": "{resources.archives.url}", "data_selector": "games", }, "include_from_parent": ["month", "username"], }, ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="chess_com_pipeline", destination="duckdb", dataset_name="chess_com_data", ) load_info = pipeline.run(chess_com_source()) print(load_info) if __name__ == "__main__": get_data()
Loading only new games. The API has no "changed since" filter. Games are published in monthly archives, and only the current month still grows. So the cursor is the archive month (YYYY/MM, taken from the archive URL). Each run requests the last month it saw plus every newer month: "primary_key": [] turns off the boundary de-duplication that would otherwise skip the still-growing month. Games merge on uuid, so the re-fetched month does not duplicate rows. See incremental loading.
To add more endpoints, add a resource per row of the table above. A path with {username} takes it from {resources.players.username}, the same way players_profiles does. dlt also maintains a verified chess source (dlt init chess duckdb) that loads players, profiles and monthly games with its own archive tracking.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource: players_profiles, archives and games. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("chess_com_pipeline").dataset() games_df = data.games.df() print(games_df[["url", "time_class", "end_time"]].head())
SQL (DuckDB example):
SELECT time_class, count(*) AS games FROM chess_com_data.games GROUP BY time_class ORDER BY games DESC;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("chess_com_pipeline").dataset() data.games.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Chess.com data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI harness:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-platform— Deploy, schedule, and monitor your pipeline in production.
uv run dlthub ai toolkit install data-exploration uv run dlthub ai toolkit install dlthub-platform
Was this page helpful?
Community Hub
Need more dlt context for Chess.com?
Request dlt skills, commands, AGENT.md files, and AI-native context.
Available Pipelines
Chess.com to Amazon S3
Chess.com’s read-only Published-Data API exposes public player, game, club, tournament, country, puzzle, streamer, and leaderboard data as JSON/JSON-LD
Destination: Amazon S3
Chess.com to Databricks
Chess.com’s read-only Published-Data API exposes public player, game, club, tournament, country, puzzle, streamer, and leaderboard data as JSON/JSON-LD
Destination: Databricks
Chess.com to DuckDB
Chess.com PubAPI is a read-only REST API that provides access to public data such as player profiles, game archives, and tournament information
Destination: DuckDB
Chess.com to PostgreSQL
Chess.com’s read-only Published-Data API exposes public player, game, club, tournament, country, puzzle, streamer, and leaderboard data as JSON/JSON-LD
Destination: PostgreSQL
Chess.com to Snowflake
Chess.com’s read-only Published-Data API exposes public player, game, club, tournament, country, puzzle, streamer, and leaderboard data as JSON/JSON-LD
Destination: Snowflake