Skip to content
moxon home

Tic-Tac-Toe Fetch

The /tic-tac-toe/fetch endpoint retrieves information about a Tic-Tac-Toe game. You can use the identifier of a game in progress to display it, or create a new game if no ID is provided.

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

Parameters

  • usernamestringrequired

    The username of the player

  • gamestringoptional

    The identifier of the game to display. If it is not provided, a new game identifier is generated

  • privatebooleanoptional

    JSON boolean: true to create a private game (default: false). Only taken into account when the game is created

Code Examples

Response Fields

  • idstring

    Game identifier

  • movesobject[]

    Array of moves made in the game

  • playersstring[]

    Array of player usernames

  • turnstring|null

    Username of the player whose turn it is

  • statusstring

    Game status (waiting or ready)

  • privateboolean

    Whether the game is private

  • 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

Game Statuses

StatusDescription
waitingThe game has fewer than 2 players
readyThe game has 2 players and is ready to be played

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

When a new game is created, the user is automatically added to the list of players. Private games are not shown in the public game list but can still be joined if you know the game ID.