lichess-org / api

Lichess API documentation and examples
https://lichess.org/api
GNU Affero General Public License v3.0
442 stars 147 forks source link

Add gif export fields for study endpoint #201

Closed jalpp closed 2 years ago

jalpp commented 2 years ago

for Study endpoints there is only option to export PGN of it, it’s good for study that contain games but for studies that have puzzles in them it’s very hard to load up a chess position from empty PGNs. In the study section “share” there is export gif option but it’s not available via API, which if added can be helpful.

For example in this study

https://lichess.org/study/cy2su9v3 There is empty PGN( [no initial fen available to set up position] but contain comments and answer to puzzle)

Use Case: I want to have access to studies’s fen/ gif containing the puzzles so when a user paste this links in discord my bot will automatically render it in images and add comments below it so it’s way easier to see the content of studies

Thanks for reading this request.

benediktwerner commented 2 years ago

What do you mean with "empty PGN"? That study certainly doesn't have an empty PGN.

And the GIF export is already usable via "the API". The GIF URLs are just https://lichess.org/study/<study id>/<chapter id>.gif.

niklasf commented 2 years ago

Verified study and chapter PGN have the expected [FEN "..."] headers.

jalpp commented 2 years ago

Ok thanks just wondering where can I get the chapter id? Because the study links only have the study id, and don’t think I can access study ids.. because I can’t use the study id followed by chapter id gif

niklasf commented 2 years ago

The study PGN https://lichess.org/study/cy2su9v3.pgn contains games with

[Site "https://lichess.org/study/cy2su9v3/mVBCzAfd"]

where the last component of the path represents the chapter.

Alternatively, curl https://lichess.org/study/cy2su9v3 -H Accept:application/vnd.lichess.v4+json delivers JSON.

jalpp commented 2 years ago

Ok great, sorry I didn’t know PGN contain everything once I get the command running I will share in lichess discord! Thanks for help really appreciate it 👍