Is there a public API call for getting the PGN of a *single* game?

Sort:
AlphaCanisMajor

Given a URL such as:

https://www.chess.com/live/game/4893975413

 

I want to make a script that can download the PGN (I don't want to click on the download button manually). I have a list of game URLs from my club's ladder games, and I want to make a for loop that, in each iteration, would automatically get the PGN (or JSON data that includes the PGN). I've looked through the public API page but I didn't see a way to do this. I see ways to download multiple games given a date range and a player. But, I didn't see anything that would solve my problem. Am I overlooking anything and is there a solution? Thanks in advance!

Tricky_Dicky

No, sorry. You have to go through a player archive.

rasusu

I feel like this should be in the API, it's pretty straightforward and useful

Saber4

I know this is late, but you can go to the game in a player's archive and parse out the PGN from the response, should be easy enough.

https://api.chess.com/pub/player/rasusu/games/2022/04

 

 

rasusu

Yeah but it's just unnecessary computation right? why for-loop through every game a player's ever played to find one matching game ID, vs just giving the game id directly and getting a PGN in response? Seems like a sensible API endpoint, specifically getting a game vs being handed every game ever of a user

bitbanger

+1. In a REST API, it's almost universally expected to be able to fetch a single resource by it's identifier. lichess.org for instance has:
GET lichess.org/game/export/{gameId}

If chess.com was open source, I'd volunteer to add this API