API for getting game details for millions of chess games.
http://chess.rest/gameref
Our Chess Gallery Game Reference API is private. To maintain our service level we ratelimit the number of API calls. For paid plans this limit is increased according to the service level described in the plan.
For public calls you don't need to pass any API key. Just invoke the endpoint (see examples below). For paid subscriptions you need to pass the API key.
Currently we support API Key based authentication. Please set a request header 'X-Chess-Api-Secret' with value of your API key. Alternatively you can also pass api_key= as a request parameter, though we strongly discourage this mode of passing the key.
This page just serves as a high level reference doc. For full upto date API documentation visit http://chess.rest/gameref/
Get the game details for the given game id.
ParametersParameter Name | Parameter Type | Description |
---|---|---|
id | string | Game id string |
curl -v -i -X POST -H 'X-Chess-Api-Secret: <api_key>' -d id=__bxTnllmGC3Xo2nNsop5QeF http://chess.rest/gameref/game.jsonThe above call will produce a response like this.
{ "success": { "total": "1" }, "contents": { "game": { "id": "__bxTnllmGC3Xo2nNsop5QeF", "event": "?", "site": "?", "game_date": "1999-00-00", "game_year": "1999", "round": null, "player_white": "Krahl, Wolfgang", "player_black": "Gerwert, Thomas", "result": "0-1", "player_whiteelo": null, "player_blackelo": null, "player_whiteuscf": null, "player_blackuscf": null, "player_whitena": null, "player_blackna": null, "player_whitetype": null, "player_blacktype": null, "event_date": "1999-00-00", "event_sponsor": null, "event_section": null, "event_stage": null, "event_board": null, "open_opening": null, "open_varation": null, "open_subvariation": null, "open_eco": "A20", "open_nic": null, "time_time": null, "time_utctime": null, "time_utcdate": null, "time_timecontrol": null, "startpos_setup": null, "startpos_fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "end_termination": null, "annotator": null, "mode": null, "plycount": "42" } } }
Search the chess.gallery database
ParametersParameter Name | Parameter Type | Description |
---|---|---|
result | string | Get the games with this result. e.g. 1-0 for white win, 0-1 for black win 1/2-1/2 for a draw |
yearop | string | "=" or ">=" or "<=". Used as the operator while filtering based on year |
player1_name | string | Name of the player |
player1_color | string | The color of the piece the given player is playing. black or white |
player2_name | string | Name of the player |
player2_color | string | The color of the piece the given player is playing. black or white |
curl -v -i -X POST -H 'X-Chess-Api-Secret: <api_key>' -d result=1-0 -d yearop="=" -d year=1999 -d "player1_name=Kasparov, Garry" -d player1_color=black http://chess.rest/gameref/search.jsonThe above call will produce a result something similar to the one below.
{ "success": { "total": "15", "start": 0, "limit": 5 }, "contents": { "games": [ { "id": "noTustvox5iwwblzxTEQ_weF", "player_white": "Topalov, Veselin", "player_black": "Kasparov, Garry", "result": "0-1" }, { "id": "e5L0fZ3sNYEaP_K27_qsugeF", "player_white": "Kasimdzhanov, Rustam", "player_black": "Kasparov, Garry", "result": "0-1" }, { "id": "Z23upsnv9OsY4acnDqiaLAeF", "player_white": "Svidler, Peter", "player_black": "Kasparov, Garry", "result": "0-1" }, { "id": "5qpq7VwaSDZOSeAh4Mk04QeF", "player_white": "Anand, Viswanathan", "player_black": "Kasparov, Garry", "result": "0-1" }, { "id": "dr2LdZnbLKGFNESnPCCpmQeF", "player_white": "Ivanchuk, Vassily", "player_black": "Kasparov, Garry", "result": "0-1" } ] }
Get the PGN (Portable Game Notation) for the given game id.
ParametersParameter Name | Parameter Type | Description |
---|---|---|
id | string | Game id string |
curl -v -i -X POST -H 'X-Chess-Api-Secret: <api_key>' -d id=__bxTnllmGC3Xo2nNsop5QeF http://chess.rest/gameref/pgn.json
{ "success": { "total": "1" }, "contents": { "pgn": "[Event \"?\"]\r\n[Site \"?\"]\r\n[Date \"1999.??.??\"]\r\n[Round \"?\"]\r\n[White \"Krahl, Wolfgang\"]\r\n[Black \"Gerwert, Thomas\"]\r\n[Result \"0-1\"]\r\n[ECO \"A20\"]\r\n[EventDate \"1999.??.??\"]\r\n[PlyCount \"42\"]\r\n\r\n1.c4 e5 2.a3 a5 3.Nc3 Nc6 4.Qa4 d6 5.Nd5 Bd7 6.e4 Nd4 7.Qd1 c6 8.Nc3 Nf6 \r\n9.d3 b5 10.Bg5 bxc4 11.dxc4 Be7 12.g3 Rb8 13.Rb1 h6 14.Bxf6 Bxf6 15.f4 \r\nexf4 16.gxf4 Bh4+ 17.Kd2 Qb6 18.Na4 Nb3+ 19.Kc2 Qe3 20.Qxd6 Nd4+ 21.Kd1 \r\nQe1# 0-1" } }
Get random game from the chess.gallery database.
ParametersParameter Name | Parameter Type | Description |
---|
curl -v -i -X POST -H 'X-Chess-Api-Secret: <api_key>' http://chess.rest/gameref/random.json
{ "success": { "total": 1 }, "contents": { "games": [ { "id": "R1eI25TEQStkTdnJytXJEgeF", "player_white": "Kristiansson, Olafur", "player_black": "Amos Bruce M", "result": "1/2-1/2" } ] } }
Search player names.
ParametersParameter Name | Parameter Type | Description |
---|---|---|
name | string | Name of the player. Full Name is not required. |
curl -v -i -X POST -H 'X-Chess-Api-Secret: <ap_key>' -d name=Kristi http://chess.rest/gameref/player/search.json
{ "success": { "total": "253", "start": 0, "limit": 5 }, "contents": { "players": [ { "id": "ZoUPHHicbDbuBdvHgBnyvweF", "name": "Aandal, Kristian" }, { "id": "zaHIO3vAtaAv_urNLguDBweF", "name": "Adondaki, Kristina" }, { "id": "vZZpbjC_M3_qRU5cxKkvfweF", "name": "Ahonen, Kristian" }, { "id": "BCQ1jQdZ2wo8puIcXlmH6geF", "name": "Apanaviciute, Kristina" }, { "id": "K47hrLX_1y6iJk3Fr2TL_AeF", "name": "Apulcheva, Kristina" } ] } }
1 API Key |
2000 API Calls / day |
Best in class backend tools |
Easy to use REST API |
Immediate provisioning |
1 API Key |
5000 API Calls / day |
Best in class backend tools |
Easy to use REST API |
Immediate provisioning |
1 API Key |
15000 API Calls / day |
Best in class backend tools |
Easy to use REST API |
Immediate provisioning |