Skip to content
moxon home

Online Tic-Tac-Toe

The /tic-tac-toe endpoint allows playing and storing an online Tic-Tac-Toe game. Games are stored for 1 hour and support both public and private modes.

posthttps://api.moxon.dev/v5/tic-tac-toe
Try itpost/v5/tic-tac-toe

Parameters

  • usernamestringrequired

    The username making the move

  • movestringrequired

    The move played in row-column format (e.g., 1-1, 2-2, 3-3)

  • sessionstringrequired

    The user's session identifier

  • gamestringrequired

    The game identifier for connection. If the game does not exist, it will be created

Move Format

The board is a 3x3 grid with positions numbered as follows:

1-1 | 1-2 | 1-3
----|-----|----
2-1 | 2-2 | 2-3
----|-----|----
3-1 | 3-2 | 3-3

Code Examples

Response Fields

  • messagestring

    Status message about the move

  • winnerstring|null

    Username of the winner (if game is over)

  • loserstring|null

    Username of the loser (if game is over)

  • tieboolean

    Whether the game ended in a tie

Error Responses

  • 429Global rate limit exceeded.Global API rate limit reached
  • 429You have exceeded the limit of X requests per hour.Hourly IP/token limit reached
  • 400Rate limit exceeded. Try again in X seconds.Per-user short-window limit
  • 400Invalid move. Please provide a valid move (e.g., 1-1, 2-2, 3-3).Invalid move format
  • 400Game is full, you can only watch.Game already has two players
  • 400Please wait for the other player to make a move.Not your turn
  • 400Move already made. Please choose a different move.Cell already occupied
  • 400Session ID mismatchSession doesn't match the player

Error Handling

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

  • 400Please provide a username (?username={username})The username parameter is missing
  • 400Please provide a valid move (&move={move})The move parameter is missing or invalid
  • 400Please provide a valid session ID (&session={ID})The session parameter is missing or invalid
  • 400Please provide a valid game ID (&game={ID})The game parameter is missing or invalid

When a game is over, the request will return the winner and loser names, as well as whether there is a tie.