ChessDotCom is a minimal wrapper for the official Chess.com REST API. Key features:
- All responses are fully typed.
- Logical beautification of field names. (e.g.
@id
becomesID
) - Built-in handling of PGN data types.
- Internal request management to prevent API throttling.
- ZERO external dependencies!
This package is designed to be incredibly lightweight and simple to use, mirroring the offering of the official Chess.com API.
ChessDotCom has been developed and fully tested with Go version 1.19
. While it will likely work with other versions, it is not recomended.
Install the package:
go get github.com/A-ndy-git/chessdotcom
Import into your project:
import (
"github.com/A-ndy-git/chessdotcom"
)
You probably shouldn't. ChessDotCom is primarily a personal education project. Nevertheless, its simple enough to provide value if you need it.
Create a new client instance, and you are done! Simples!
client := chessdotcom.New()
// Client is instantiated and ready to be used. E.g.
res, err := client.PlayerProfile("magnuscarlsen")
...
Automatically created GoDoc
docs are available here. High level methods are listed below.
- Profile - Get additional details about a player in a game
res, err := client.PlayerProfile("erik")
if err != nil {
// handle error
}
// res ->
{
"Avatar": "https://images.chesscomfiles.com/uploads/v1/user/41.5434c4ff.200x200o.5b102889d835.jpeg",
"PlayerId": 41,
"ID": "https://api.chess.com/pub/player/erik",
"URL": "https://www.chess.com/member/erik",
"Name": "Erik",
"Username": "erik",
"Followers": 4340,
"Country": "https://api.chess.com/pub/country/US",
"Location": "Bay Area, CA",
"LastOnline": 1669316678,
"Joined": 1178556600,
"Status": "staff",
"IsStreamer": false,
"Verified": true
}
- Stats - Get ratings, win/loss, and other stats about a player's game play, tactics, lessons and Puzzle Rush score.
client.PlayerStats("magnuscarlsen")
- Games - Array of Daily Chess games that a player is currently playing.
client.PlayerGames("magnuscarlsen")
- Game Archive - Array of monthly archives available for this player.
client.PlayerGameArchive("magnuscarlsen")
- Games to Move - Array of Daily Chess games where it is the player's turn to act.
client.PlayerGamesToMove("magnuscarlsen")
- Archive PGN - standard multi-game format PGN containing all games for a month.
client.PlayerAchivePGN("magnuscarlsen", "2022", "01")
- Game Monthly Archive - Array of Live and Daily Chess games that a player has finished.
client.PlayerGameMonthlyArchive("magnuscarlsen", "2022", "01")
- Clubs - List of clubs the player is a member of, with joined date and last activity date.
client.PlayerClubs("magnuscarlsen")
- Tournaments - List of tournaments the player is registered, is attending or has attended in the past.
client.PlayerTournaments("magnuscarlsen")
- Titled Players - List of titled-player usernames.
client.PlayerTitledPlayers()