Web App: HTTP & WebSocket API#
The web app is a FastAPI server fronting the same yasuki_core engine the desktop client uses. The
server is authoritative: clients never mutate game state directly — they send intents over a WebSocket,
the server applies them through the engine, and broadcasts the resulting state. Card browsing, room
management, and configuration are plain REST; live gameplay runs over the WebSocket protocol below.
REST Endpoints#
Cards#
Method |
Path |
Description |
|---|---|---|
|
|
List/search cards (supports Scryfall-style syntax) |
|
|
Get card details with all print variations |
|
|
Get random cards |
|
|
List all card sets |
|
|
List game formats in chronological order |
|
|
List deck types (Dynasty, Fate) |
|
|
List all clans |
|
|
List all card types |
Game Rooms#
Method |
Path |
Description |
|---|---|---|
|
|
Create a new game room |
|
|
List available (waiting, not full) rooms |
|
|
Get room details |
|
|
Delete a room (requires delete token) |
|
|
List players in a room |
Other#
Method |
Path |
Description |
|---|---|---|
|
|
API info and version |
|
|
Health check |
|
|
Client configuration (image base URL) |
WebSocket Protocol#
Connect to WS /ws/{room_id} for real-time game communication.
Flow#
Client creates a room via
POST /api/rooms(receivesroom_idanddelete_token)Client connects to
/ws/{room_id}Client sends a
JOINmessage with player nameServer responds with
HELLOcontaining room infoClients exchange
ACTIONmessagesServer broadcasts
STATEupdates to all players
Client → Server Messages#
Join Room:
{
"type": "JOIN",
"room": "room-id",
"join": {
"name": "PlayerName"
}
}
Send Action:
{
"type": "ACTION",
"room": "room-id",
"action": {
"kind": "PLAY_CARD",
"card": "card-id"
}
}
Ping (keepalive):
{
"type": "PING"
}
Server → Client Messages#
Hello (on join):
{
"type": "HELLO",
"room": "room-id",
"you": "PlayerName",
"players": ["Player1", "Player2"],
"seq": 0
}
State Update:
{
"type": "STATE",
"room": "room-id",
"seq": 1,
"state": {
"turn": 0,
"phase": "setup",
"player_states": {}
}
}
Error:
{
"type": "ERROR",
"room": "room-id",
"message": "Error description"
}
Close Codes#
Code |
Meaning |
|---|---|
|
Message too large (>4 KB) |
|
Room full |
|
Room not found |
|
Too many connections from this IP |
Action Kinds#
Kind |
Fields |
Description |
|---|---|---|
|
|
Play a card by ID |
|
— |
Draw a card |
|
— |
Pass (advances turn) |
|
|
Shuffle a deck ( |
Message schemas are defined in src/yasuki_web/schemas.py.