Skip to content

Instantly share code, notes, and snippets.

View MathPlayer's full-sized avatar
🍀
🌩️🧙‍♂️

Bogdan Popescu MathPlayer

🍀
🌩️🧙‍♂️
View GitHub Profile
@MathPlayer
MathPlayer / instructions.md
Last active May 3, 2022 11:27
Get all chess.com games for a given user(name)

Run this one-liner in a bash/zsh/... terminal to get all games of a given user in PGN format:

export CHESS_USER=<the-username>; for MONTH_URL in $(curl -Ls "https://api.chess.com/pub/player/$CHESS_USER/games/archives" | jq -rc ".archives[]"); do echo >&2 "Fetching games for $CHESS_USER for month url: $MONTH_URL"; curl -Ls "$MONTH_URL" | jq -rc ".games[].pgn" ; done >> "$(date -u +'%Y-%m-%d-%H-%M-%S')-$CHESS_USER-games.pgn"

Tools required: curl, jq (date should exist on any modern enough system).