5

How can I export all my games played on chess.com?

For example to import to another program for analysis.

Exporting from the chess.com games list only shows the most recent 50 games.

3 Answers 3

4
  1. OpeningTree.com allows you to export all games played as White or Black by username.

  2. Python wrapper for chess.com API by Artur Saradzhyan (I have not tested this.)

  3. Manually export games from the chess.com game list, 50 at a time by date range (may require trivial deduplication). Supports chess clock info.

2

@qwr’s answer to their own question mentions a “Python wrapper for chess.com API,” but I think it’s worthwhile answering with the API itself, because it’s very accessible without any need to know/use Python. Hence…

Chess.com has, a fairly recently provided, Published Data API. See announcement by Ben Curtis, on May 10, 2022: “Published-Data API”:

The PubAPI is a read-only REST API that responds with JSON-LD data. Our goal is to re-package all currently public data from the website and make it available via the PubAPI. "Public Data" is information available to people who are not logged in, such as player data, game data, and club/tournament information. This excludes private information that is restricted to the logged in user, such as game chat and conditional moves.

The key with using a REST API is to construct the appropriate URL that represents your query. (See Zell Liew, “Understanding And Using REST APIs, Smashing Magazine, May 20, 2021, for the most-accessible intro I know about getting information from a REST API.)

For example, to find out some basic information about Hikaru, specifically his “user profile,” put the following URL in your browser’s address bar:

https://api.chess.com/pub/player/hikaru

Your browser will return with:

    
avatar  "https://images.chesscomf…0x200o.f323efa57fd0.jpeg"
player_id   15448422
@id "https://api.chess.com/pub/player/hikaru"
url "https://www.chess.com/member/Hikaru"
name    "Hikaru Nakamura"
username    "hikaru"
title   "GM"
followers   983906
country "https://api.chess.com/pub/country/US"
location    "Sunrise, Florida"
last_online 1662743764
joined  1389043258
status  "premium"
is_streamer true
twitch_url  "https://twitch.tv/gmhikaru"
verified    true

For basic statistics about a player (ratings, win/loss, and other stats about a player's game play, tactics, lessons and Puzzle Rush score), tack on “/stats” to the previous URL:

https://api.chess.com/pub/player/hikaru/stats

This produces a long-ish regurgitation of statistics, for example, that Hikaru’s last bullet rating was 3352:

. . . 

chess_bullet    
last    
rating  3352
date    1661276020
rd  41
best    
rating  3570
date    1605136047
game    "https://www.chess.com/game/live/5710095242"
record  
win 10136
loss    1376

. . .

Most directly on point to your question, you can get the PGN for all games a given player (i.e., you) played in a month. For Hikaru, for April 2022, the URL would be:

https://api.chess.com/pub/player/hikaru/games/2022/04/pgn

and your browser will download a multi-game PGN file.

AFAICT, you can download a player’s game for a particular month, but not for any broader period.

Since the URLs are very simple, it would be pretty easy to construct several year’s worth of URLs with a text editor and copy/pasting to change the years and months.

2
  • 1
    Very nice. Of course, if you're going to make multiple API requests and process the results, you might as well use a python wrapper to do all that
    – qwr
    Sep 10, 2022 at 3:20
  • @qwr That depends on (a) How many months of games you have and (b) how familiar you are with Python (or the fixed cost of becoming sufficiently familiar). Sep 10, 2022 at 3:40
0

Use my API to get all games.

https://github.com/ChameleonRed/cw_download_chess_com_games

It is very simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.