The CS 240 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.
|
[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 and player color. 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. |
This section is only applicable during phase 6. Use this to test the websocket functionality of your server