Skip to content

Tic-Tac-Toe Play

The /tic-tac-toe/:game endpoint plays a move in an existing game using a REST method.

Parameters

ParameterRequiredDescription
gameYesThe game identifier (URL parameter)
usernameYesThe username making the move
moveYesThe move played (e.g., 1-1, 2-2, 3-3)
sessionYesThe user's session identifier

Good to know

The game parameter is part of the URL path. The other parameters are sent as a JSON body with Content-Type: application/json.

Response Fields

FieldTypeDescription
messagestringStatus message about the move
winnerstring|nullUsername of the winner (if game is over)
loserstring|nullUsername of the loser (if game is over)
tiebooleanWhether the game ended in a tie

Code Examples

curl -X PATCH \
  -H "Content-Type: application/json" \
  -d '{
    "username": "alice",
    "move": "1-1",
    "session": "abc123"
  }' \
  "https://api.sylvain.sh/v4/tic-tac-toe/VWXYZ"

Try It

Error Handling

If parameters are missing or invalid, the API will return an error:

Error MessageDescription
Invalid move. Please provide a valid move (e.g., 1-1, 2-2, 3-3).Invalid move format
Game is full, you can only watch.Game already has two players
Please wait for the other player to make a move.Not your turn
Move already made. Please choose a different move.Cell already occupied
Session ID mismatchSession doesn't match the player