cjsaylor/chessbot

Create link to import PGN into lichess.

cjsaylor opened this issue · 0 comments

Lichess supports a POST endpoint for importing a game via PGN.

Here is an example request:

curl 'https://lichess.org/import' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' \
  -H 'Referer: https://lichess.org/paste' \
  -H 'Accept-Encoding: gzip, deflate, br' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  --data 'pgn=1.d2d4+d7d5+2.e2e3+g8h6+3.f1b5+c7c6+4.b5d3+e7e6+5.g1f3+f8b4+6.c2c3+b4e7+7.c3c4+e8g8+8.c4c5+b7b6+9.b2b3+b6c5+10.d4c5+e7c5+11.c1a3+d8d6+12.d1d2+c5a3+13.e1g1+a3b4+14.d2c1+c8a6+15.d3a6+b8a6+16.a2a3+b4a5+17.b3b4+a5d8+18.f3d4+a8c8+19.b1c3+h6g4+20.h2h3+*'

It responds with a 303 with a location header that we can redirect the user to.