Python SDK — Rooms

Room Management — client.rooms

create
client.rooms.create(
    player_token: str,
    room_name: str,
    max_players: int = 4,
    password: str | None = None,
    host_switch: bool = False,
    realtime: bool = False,
    player_data: Any = None,
    rules: Any = None,
) -> RoomCreateResponse

Creates a new game room with optional password, rules and host player data.

list
client.rooms.list(search: str | None = None, limit: int | None = None, rules_cls: type | None = None) -> RoomListResponse

Retrieves available game rooms. Pass rules_cls to deserialize each room's rules.

join
client.rooms.join(player_token: str, room_id: str, password: str | None = None, player_data: Any = None) -> RoomJoinResponse

Joins an existing game room with optional password and player data.

leave
client.rooms.leave(player_token: str) -> RoomLeaveResponse

Leaves the current game room.

get_players
client.rooms.get_players(player_token: str, data_cls: type | None = None) -> RoomPlayersResponse

Retrieves all players in the current room with typed player_data.

heartbeat
client.rooms.heartbeat(player_token: str) -> HeartbeatResponse

Sends a heartbeat to maintain connection in the game room.

get_current
client.rooms.get_current(player_token: str, rules_cls: type | None = None) -> CurrentRoomResponse

Gets comprehensive room state including pending actions and updates.

stop
client.rooms.stop(player_token: str) -> RoomStopResponse

Stops the current game room (host only). Completely removes the room and all associated data.

kick
client.rooms.kick(player_token: str, player_id: int) -> RoomKickResponse

Kicks a player from the game room (host only). Cannot kick yourself.

update_password
client.rooms.update_password(player_token: str, password: str | None = None) -> RoomPasswordResponse

Updates the room password (host only). Pass None to remove it.

Room lifecycle and host controls

A room is one live game session. Create makes the caller the host; list browses public rooms without needing a player token; join enters by id — with a password for protected rooms. Players lists the occupants of the caller's current room, and leave, heartbeat and current manage the membership lifecycle.

The host gets the controls: stop the room, kick a member, set or clear the password. Room custom data holds shared state — map, mode, phase — that members read to stay in sync, and matchmaking lobbies spawn a linked room when the host starts.

  • Send heartbeat on an interval while joined — lapsed memberships get cleaned up server-side.
  • Room titles are validated against your game's room rules at creation, same pipeline as player names.
  • Choose rooms for direct create-and-join flows, matchmaking when players need a browsable lobby first.
  • Calls are synchronous functions — wrap them in asyncio.to_thread or your engine's job system when the game loop cannot block, and reuse one client across coroutines.