Skip to content

Instantly share code, notes, and snippets.

@misTrasteos
Last active April 22, 2022 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misTrasteos/d536a54ca8bdf87f51f797a49585b179 to your computer and use it in GitHub Desktop.
Save misTrasteos/d536a54ca8bdf87f51f797a49585b179 to your computer and use it in GitHub Desktop.
Lichess API

How to ...

... export games of a user

Official Docs

curl --location --request GET 'https://lichess.org/api/games/user/{USER}?max=1&analysed=true&clocks=true&evals=true&opening=true&literate=true' \
--header 'Authorization: Bearer {PAT}'

This query options include clock, annotations and some relevant information about the game.

replace PAT with your PAT, no extra scope is required.

# very WIP
!pip install python-chess
import chess.pgn
pgn = open("game.pgn")
game = chess.pgn.read_game(pgn)
print( type(game) )
ini = game.game()
print(type(ini))
for move in game.mainline_moves():
print( move )
print( type(move) )
print( move.eval() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment