openchess logo

openchess

github repo

About

openchess is a simple REST API that generates SVGs for 8x8 board games like chess and checkers. Inspired by deckofcardsapi.com, openchess allows users to create games, move and set pieces, and view games using simple HTTP GET requests.

openchess is built using Express in Node.js. For storing game information and caching simple SVGs, we used Redis. openchess is tested using Jest.

API Reference

Create new game

Request

GET /api/new

Parameter Type Description
game string Default board layout for the game. Options are chess, checkers, or none
bsize number Board size in pixels
animation boolean Enables peice movement animation
fen string FEN code for initial layout of chess board

Response

Type: application/json

Get game

Request

GET /api/game/${id}

Parameter Type Description
id string ID of game to retrieve

Response

Type: image/svg+xml

Move game piece

Request

GET /api/game/${id}/move/${from}-${to}

Parameter Type Description
id string ID of game to retrieve
from string Coordinate of piece to move
id string Coordinate of tile to move piece to

Response

Type: image/svg+xml

Reset game to default state

Request

GET /api/game/${id}/reset

Parameter Type Description
id string ID of game to retrieve

Response

Type: image/svg+xml

Get game options

Request

GET /api/game/${id}/options

Parameter Type Description
id string ID of game to retrieve

Response

Type: application/json

Set piece at tile

Request

GET /api/game/${id}/set/${tile}-${color}-${piece}

Parameter Type Description
id string ID of game to retrieve
tile string Coordinate of tile to set piece at
color string Color of game piece
piece string Piece type

Response

Type: image/svg+xml

Remove piece at tile

Request

GET /api/game/${id}/remove/${tile}

Parameter Type Description
id string ID of game to retrieve
tile string Coordinate to remove piece from

Response

Type: image/svg+xml