.NET (C#) SDK — Players

Player Management

RegisterPlayer
public Task<PlayerRegisterResponse> RegisterPlayer<T>(string name, T? playerData = null, CancellationToken ct = default)

Registers a new player with optional custom data. Uses generic type for player data with System.Text.Json serialization.

RegisterPlayerWithSteam
public static Task<PlayerRegisterResponse> RegisterPlayerWithSteam<T>(Client client, string steamTicket, string? steamIdentity = null, string? name = null, T? playerData = null, string? playerToken = null, bool restore = false, CancellationToken ct = default)

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.

Example Usage:

// Hex-encode the ticket bytes from GetAuthTicketForWebApi
var reg = await Players.RegisterPlayerWithSteam<PlayerData>(client, ticketHex, "michitai");
var playerToken = reg.Private_key;
RegisterPlayerWithGoogle
public static Task<PlayerRegisterResponse> RegisterPlayerWithGoogle<T>(Client client, string googleAuthCode, string? googleIntegrityToken = null, string? name = null, T? playerData = null, string? playerToken = null, bool restore = false, CancellationToken ct = default)

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.

AuthenticatePlayer
public Task<PlayerAuthResponse<T>> AuthenticatePlayer<T>(string playerToken, CancellationToken ct = default)

Authenticates a player using their private token. Returns player information with typed data support.

GetAllPlayers
public Task<PlayerListResponse> GetAllPlayers(CancellationToken ct = default)

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

SendPlayerHeartbeatAsync
public Task<PlayerHeartbeatResponse> SendPlayerHeartbeatAsync(string playerToken, CancellationToken ct = default)

Updates player heartbeat to maintain online status.

LogoutPlayerAsync
public Task<PlayerLogoutResponse> LogoutPlayerAsync(string playerToken, CancellationToken ct = default)

Logs out a player and updates their last logout timestamp.

RenamePlayerAsync
public Task<PlayerRenameResponse> RenamePlayerAsync(string playerToken, string newName, CancellationToken ct = default)

Renames a player to a new name. Validates name length (2-50 characters) and requires player authentication.

DeleteAccountAsync
public static Task<PlayerDeleteResponse> DeleteAccountAsync(Client client, string playerToken, CancellationToken ct = default)

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.

RestoreAccountAsync
public static Task<PlayerRestoreResponse> RestoreAccountAsync(Client client, string playerToken, CancellationToken ct = default)

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 set after confirmation.

BanPlayerAsync
public Task<PlayerBanResponse> BanPlayerAsync(int playerId, EBanTime banDuration, string? banReason = null, CancellationToken ct = default)

Bans a player from the game with specified duration (Hour, Day, Week, Month, Quarter, Year, Forever) and optional reason. Requires private API token.

UnbanPlayerAsync
public Task<PlayerUnbanResponse> UnbanPlayerAsync(int playerId, CancellationToken ct = default)

Unbans a previously banned player. Requires private API token.

IsBanned
public static bool IsBanned(ApiResponse response)

Checks if an API response indicates the player is banned. Returns true if the error message contains "You are banned".

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.
  • Methods are Task-based async — await them and pass a CancellationToken tied to your game's lifetime so in-flight requests cancel cleanly on shutdown.