Help with Chess.com API: Retrieve Elo vs. Number of Rapid Games

Sort:
kelevraslevin

Hi everyone,

I’m trying to use the Chess.com Public API to create a graph that shows the relationship between Elo and the number of games played, specifically for rapid games, for a few players whose usernames I know.

Here’s what I’d like to do:

For each player, retrieve their rapid Elo and the total number of rapid games played.
Plot these on a graph, with :

X-axis: Number of rapid games played.
Y-axis: Elo in rapid games.

Do you know if it's feasible and if yes how to do it?

Thanks a lot!

Martin_Stahl
kelevraslevin wrote:

Hi everyone,

I’m trying to use the Chess.com Public API to create a graph that shows the relationship between Elo and the number of games played, specifically for rapid games, for a few players whose usernames I know.

Here’s what I’d like to do:

For each player, retrieve their rapid Elo and the total number of rapid games played.
Plot these on a graph, with :

X-axis: Number of rapid games played.
Y-axis: Elo in rapid games.

Do you know if it's feasible and if yes how to do it?
Thanks a lot!

The Public API player stats endpoint includes the ratings and the wins, losses, and and draws so you could calculate total rated games that qualify for stats inclusion.

Kalel1130

Hi Slevin (great name by the way),

There are two endpoints to help you do that:

  1. https://api.chess.com/pub/player/<usernerme>/games/archives ==> this helps you get all the game archives for a player. And it will retrieve a list of archives, like so:
{
"archives": [
"https://api.chess.com/pub/player/<username>/games/2020/03",
"https://api.chess.com/pub/player/<username>/games/2020/04",
"https://api.chess.com/pub/player/<username>/games/2020/05",
"https://api.chess.com/pub/player/<username>/games/2020/06",
]
}
 
And then from those archives you can get their games:
 
This endpoint https://api.chess.com/pub/player/<username>/games/2020/03 will give you something like that:
{
"games": [
{
"url": "url of the game",
"pgn": "PGN XXXX",
"time_control": "600",
"end_time": 1584486984,
"rated": true,
"accuracies": {
"white": 23.6,
"black": 87.6
},
"tcn": "tcn of the game",
"uuid": "uuid of the game",
"initial_setup": "",
"fen": "fen of the game",
"time_class": "blitz",
"rules": "chess",
"white": {
"rating": 718,
"result": "win",
"@id": "chess id of the player",
"username": "username",
"uuid": "uuid"
},
"black": {
"rating": 612,
"result": "timeout",
"@id": "chess profile of player",
"username": "username",
"uuid": "uuid"
},
"eco": "opening"
},
 
And from that you can get the ratings from the "rating" key.
With those information you can compile the game number and the elo evolution of the player. Here is a little website I made for you for that: