Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Antonelli-Tech-Solutions/spades/llms.txt

Use this file to discover all available pages before exploring further.

The state endpoint returns a player-specific view of the game. Cards belonging to other players’ hands are never included in any response — the server filters the full game state before sending it to each client. Spectators (observers) receive a public view with status: "spectating" that includes seats, scores, bids, and phase information, but never myHand or any other player’s hand data.

GET /api/tables/:tableId/state

Required headers: x-session-id, x-player-id
curl http://localhost:3000/api/tables/<tableId>/state \
  -H 'x-session-id: <sessionId>' \
  -H 'x-player-id: <playerId>'

Response codes

StatusMeaning
200Game state returned successfully. Body varies by phase — see Response variants below.
401Missing or invalid session.
403Player is not seated at or observing this table.
404Table not found.

Response variants

Returned before the game starts (fewer than 4 seats filled).
{
  "status": "waiting",
  "seats": {
    "north": { "playerId": "uuid", "username": "alice", "isBot": false },
    "east":  null,
    "south": { "playerId": "uuid", "username": "bob",   "isBot": false },
    "west":  null
  },
  "observers": [],
  "isHost": true,
  "hostSeat": "north"
}
status
string
required
Always "waiting" when the game has not yet started.
seats
object
required
Object keyed by seat name (north, east, south, west). Each value is either null (empty seat) or an object with playerId, username, and isBot.
observers
array
required
List of spectators currently watching the table. Each entry has playerId and username.
isHost
boolean
required
Whether the requesting player is the table host.
hostSeat
string
required
The seat occupied by the host (e.g. "north"), or null if the host is not seated.

validCards field

validCards is present in the response only when it is the requesting player’s turn to play during the playing phase. The server computes the full set of legal plays via getLegalPlays and includes them as an array of card objects (e.g. [{ "suit": "hearts", "rank": "Q" }]). Clients may use this array to highlight or restrict UI affordances — for example, greying out cards that are not in the list. However, the server re-validates every card play regardless; passing a card not in validCards to POST /api/tables/:tableId/play returns 400.

Card representation

Cards are represented as JSON objects with two fields:
FieldTypeValues
suitstring"spades", "hearts", "clubs", "diamonds"
rankstring"2""9", "10", "J", "Q", "K", "A"
Examples:
{ "suit": "spades",   "rank": "A"  }
{ "suit": "hearts",   "rank": "K"  }
{ "suit": "diamonds", "rank": "10" }
{ "suit": "clubs",    "rank": "2"  }
Note that 10 is represented as the string "10" (two characters), not as a single-character code.

Build docs developers (and LLMs) love