Python SDK — Players

Player Management — client.players

register
client.players.register(name: str, player_data: Any = None) -> PlayerRegisterResponse

Registers a new player with optional custom data. Returns player_id and private_key (the player token).

register_steam
client.players.register_steam(
    steam_ticket: str,
    steam_identity: str | None = None,
    name: str | None = None,
    player_data: Any = None,
    player_token: str | None = None,
    restore: bool = False
) -> PlayerRegisterResponse

Registers or logs in a player via a hex-encoded Steam auth ticket from ISteamUser::GetAuthTicketForWebApi (single-use — request a fresh ticket each login). Requires Steam enabled for the project in the API cabinet; the account persists via SteamID. Response includes steam_id.

Ticket minting is out of scope for this SDK (server-side tooling and tests): game clients use the built-in Steam helpers in the Unity/.NET/C++ SDKs.

register_google
client.players.register_google(
    google_auth_code: str,
    google_integrity_token: str | None = None,
    name: str | None = None,
    player_data: Any = None,
    player_token: str | None = None,
    restore: bool = False
) -> PlayerRegisterResponse

Registers or logs in via a Google Play Games server auth code. Pass restore=True only after the player explicitly confirms a deletion-restore prompt; the fresh provider credential can recover the account even after a reinstall.

authenticate
client.players.authenticate(player_token: str, data_cls: type | None = None) -> PlayerAuthResponse

Authenticates a player using their private token. Pass a dataclass as data_cls to deserialize player.player_data into it.

get_all_players
client.games.get_all_players() -> PlayerListResponse

Retrieves a list of all players (requires private API token).

heartbeat
client.players.heartbeat(player_token: str) -> PlayerHeartbeatResponse

Updates player heartbeat to maintain online status.

logout
client.players.logout(player_token: str) -> PlayerLogoutResponse

Logs out a player and updates their last logout timestamp.

rename
client.players.rename(player_token: str, new_name: str) -> PlayerRenameResponse

Renames a player (2-50 characters).

delete_account
client.players.delete_account(player_token: str) -> PlayerDeleteResponse

Schedules player-initiated account deletion. The account freezes immediately and is purged after the 30-day grace window unless restored. Keep the player credential during the window; the response includes deletion_pending and purge_after.

restore_account
client.players.restore_account(player_token: str) -> PlayerRestoreResponse

Cancels a pending deletion. This must be an explicit player action, never an automatic login or background retry. Provider-linked accounts can also restore after reinstall by signing in with the provider and restore=True after confirmation.

ban
client.players.ban(player_id: int, ban_duration: BanTime, ban_reason: str | None = None) -> PlayerBanResponse

Bans a player with a BanTime duration (HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, FOREVER) and optional reason. Requires private API token.

unban
client.players.unban(player_id: int) -> PlayerUnbanResponse

Unbans a previously banned player. Requires private API token.

is_banned
from multiplayer import is_banned
is_banned(response: ApiResponse) -> bool

Checks if an API response indicates the player is banned (error contains "You are banned" or ban_info is present).

Sessions, tokens and name rules

Register creates the player and returns the token your game stores and presents as X-Game-Player-Token. Login re-opens the session on a later run; heartbeat keeps the player marked online while they play; logout ends the session cleanly. Rotate issues a fresh credential and invalidates the old one — call it any time a token may have leaked.

Registration and rename validate the display name server-side against your game's name rules — allowed scripts, case policy and symbols, edited in the cabinet — plus the profanity screen. A rejected name comes back as a fielded error you can show the player instead of guessing why it failed.

  • Players register with just a display name — identity is the returned token, so store it like a credential.
  • Admin calls — list, ban and unban — use the API token pair. Never ship the private token in a client build.
  • Each player also carries a JSON data record — stats, loadouts, progression — that leaderboards rank server-side.
  • 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.