Getting a pgn

Sort:
kyle_b81

Is there a way to get a PGN given a game id?

Tricky_Dicky

https://www.chess.com/news/view/published-data-api

stephen_33
kyle_b81 wrote:

Is there a way to get a PGN given a game id?

You may need to refine your question because with the game_id you can open the game in a browser window and then use the 'download' button to obtain the PGN.

But something tells me you didn't mean that.

Saber4

See Eyal282 solution here: https://www.chess.com/clubs/forum/view/guide-unofficial-api-documentation

Step 1: Take a random URL you need. I will use this: https://www.chess.com/game/live/15360860817

Step 2: Go to this endpoint, the number being the ID of the game. Notice live and game are swapped for unknown reasons: https://www.chess.com/callback/live/game/15360860817

Step 3: From the unofficial endpoint of the callback fetch the date of the game.

Step 4: Use the official API to fetch all games within the same month of one of the participants ( top or bottom )

Step 5: Find the URL of the game within the result, as the URL itself is given.

Step 6: You also get a PGN.

Saber4

Had a little more time, here's the python. Should do the needful happy.png

https://pastebin.com/0Q7xHQCB