The Chess Server Web API is described below. Some of the APIs require a request body to be sent (like
/user/login and /user/register), while others require an Authorization authToken
(received at login). To view the required JSON format, click on a command below and look at the example request
body. To try out an API, modify the request as needed, and press Send.
Once you join a game, a WebSocket connection is opened for you to play in real-time.
To play, download the
client, then run it in your terminal with:
java -jar client.jar server:8080
|
[POST]
/user
|
Register a user If successful, an authorization authToken is returned. You may use the authToken with future requests that require authorization. No authorization authToken is required to call this endpoint. |
|
[POST]
/session
|
Log in a user If successful, an authorization authToken is returned. You may use the authToken with future requests that require authorization. No authorization authToken is required to call this endpoint. |
|
[DELETE]
/session
|
Logs out an authenticated user An authToken is required to call this endpoint. |
|
[GET]
/game
|
Lists all the games in the database This API does not take a request body. The response JSON lists all the games, including the board. An authToken is required to call this endpoint. |
|
[POST]
/game
|
Create a new Chess Game The request body must contain a name for the game. The response JSON contains the ID of created game, or if failed, an error message describing the reason. An authToken is required to call this endpoint. |
|
[PUT]
/game
|
Join a Chess Game The request body must contain the game ID. If no color is specified then the user is joined as an observer. An authToken is required to call this endpoint. |
|
[DELETE]
/db
|
Clear ALL data from the database This includes users and all game data. No authorization authToken is required. |