This Request For Comments covers a new per-player endpoint to provide current playing stats for each game type, and changes to the data values for games-related endpoints. Historical rating data will be obtainable from the game archives.
Please note: These endpoints should provide the same data as the website stats pages, but some aspects of these API stats will be coded from scratch; as such, we want to treat any difference as a bug and would appreciate reports covering such cases.
/pub/player/{username}/stats
Each timeclass and rules variant will have a "stats" block of approximately the same structure, identified by a key in the format of "<rules>_<timeclass>". This is always true; all livechess variants are in the "blitz" timeclass, and so even though it seems redundant these will be named like "bughouse_blitz" and "chess960_blitz".
In addition, we will be using the website timeclass names: "rapid" in place of "standard," and "bullet" in place of "lightning." The games endpoints will be updated to reflect this (see note below).
Therefore the player-stats DTO is a collection of named stats DTOs, like so:
{
"chess_daily":{ /* stats block */ },
"chess960_rapid":{ /* stats block */ },
"bughouse_blitz":{ /* stats block */ }
}
Timeclass options are: daily, rapid (previously "standard"), blitz, bullet (previously "lightning"). Rules options are: chess, chess960, crazyhouse, bughouse, kingofthehill, losers, oddschess, threecheck. Not all combinations are available. Many livechess variants only track the "last" rating info and so their stats blocks will have no "best" or "tournament" blocks. If the player has never been in a tournament, that block is not present. If the player has never won a game, the "best" block is not present.
We will only deliver stats blocks for class/rules combinations that the player has actually played — no default entries should be delivered. This means that players who have just registered and not yet played will have an empty stats object.
Each stats block contains:
{
"last":{
"rating":1500,
"rd":56.7,
"game":"web URL",
"date":123456789
},
"best":{
"rating":1500,
"game":"web URL",
"date":123456789
},
"record":{
"win":1,
"loss":2,
"draw":3,
"time_per_move":56160, // daily time class only, measured in seconds
"timeout_percent":23 // daily time class only; note: only past 3 months (same as web UI)
},
"tournament":{
"points":1,
"count":1,
"withdraw":2,
"best_finish":12, // only if greater than 3
"finished":[ // only available if the player has placed in top 3 at least once
{ /* after tournament endpoint: place, tournament link */ }
]
}
}
Breaking Change
/pub/player/{username}/games/pub/player/{username}/games/YYYY/MM
All game endpoints will have a change to the time_class values, to use the website terms for livechess "rapid" (previously "standard") and "bullet" (previously "lightning").
Does this endpoint get you what's needed for your stats and ratings projects? Are there related data we missed that are essential? If possible, please include specific examples of how you intend to use the data, especially if you request that we change this output in some way.