Multiplayer API Logo

Multiplayer API

.NET SDK for
Multiplayer Games

.NET SDK

.NET SDK Download

View on GitHub
Repository

.NET API Documentation

GameSDK

Constructor
public GameSDK(
    string apiToken, 
    string apiPrivateToken, 
    string baseUrl = "https://api.michitai.com/api",
    ILogger? logger = null
)

Initializes the SDK with API tokens and optional custom base URL.

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.

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.

Game Data

GetGameData
public Task<GameDataResponse<T>> GetGameData<T>(CancellationToken ct = default)

Retrieves global game data with System.Text.Json compatible nested objects.

UpdateGameData
public Task<SuccessResponse> UpdateGameData<T>(T data, CancellationToken ct = default)

Updates global game data (requires private API token). Uses generic type for type safety.

GetPlayerData
public Task<PlayerDataResponse<T>> GetPlayerData<T>(string playerToken, CancellationToken ct = default)

Retrieves a specific player's data using their authentication token with typed support.

UpdatePlayerData
public Task<SuccessResponse> UpdatePlayerData<T>(string playerToken, T data, CancellationToken ct = default)

Updates a specific player's data like level, score, and inventory with generic type support.

Time Management

GetServerTime
public Task<ServerTimeResponse> GetServerTime()

Retrieves current server time in multiple formats including UTC timestamp.

GetServerTimeWithOffset
public Task<ServerTimeWithOffsetResponse> GetServerTimeWithOffset(
    int utcOffset
)

Retrieves server time with specified UTC offset adjustment.

Room Management

CreateRoomAsync
public Task<RoomCreateResponse> CreateRoomAsync<T>(string gamePlayerToken,
    string roomName,
    string? password = null,
    int maxPlayers = 4,
    T? rules = null,
    CancellationToken ct = default)

Creates a new game room for multiplayer sessions with typed rules support.

GetRoomsAsync
public Task<RoomListResponse<T>> GetRoomsAsync<T>(CancellationToken ct = default)

Retrieves a list of all available game rooms with typed rules support.

JoinRoomAsync
public Task<RoomJoinResponse> JoinRoomAsync(
    string gamePlayerToken,
    string roomId,
    string? password = null,
    CancellationToken ct = default)

Joins an existing game room with optional password.

LeaveRoomAsync
public Task<RoomLeaveResponse> LeaveRoomAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Leaves the current game room.

GetRoomPlayersAsync
public Task<RoomPlayersResponse> GetRoomPlayersAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Retrieves a list of all players in the current room.

SendHeartbeatAsync
public Task<HeartbeatResponse> SendHeartbeatAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Sends heartbeat to maintain connection in game room.

GetCurrentRoomAsync
public Task<CurrentRoomResponse<T>> GetCurrentRoomAsync<T>(
    string playerToken,
    CancellationToken ct = default)

Gets comprehensive room state including player lists and pending actions with typed support.

Room Actions

SubmitActionAsync
public Task<ActionSubmitResponse> SubmitActionAsync<T>(string gamePlayerToken,
    string actionType,
    T? requestData = null,
    CancellationToken ct = default)

Submits a game action for processing by other players with typed request data.

PollActionsAsync
public Task<ActionPollResponse<T>> PollActionsAsync<T>(string gamePlayerToken, CancellationToken ct = default)

Polls for completed actions from other players with typed response data.

GetPendingActionsAsync
public Task<ActionPendingResponse<T>> GetPendingActionsAsync<T>(string gamePlayerToken, CancellationToken ct = default)

Retrieves a list of pending actions that need to be processed with typed request data.

CompleteActionAsync
public Task<ActionCompleteResponse> CompleteActionAsync<T>(string actionId,
    string gamePlayerToken,
    ActionComplete<T> request,
    CancellationToken ct = default)

Marks an action as completed with response data using typed ActionComplete parameter.

Room Updates

UpdatePlayersAsync
public Task<UpdatePlayersResponse> UpdatePlayersAsync<T>(string gamePlayerToken,
    UpdatePlayers<T> request,
    CancellationToken ct = default)

Sends updates to specific players or all players in the room with typed data support.

PollUpdatesAsync
public Task<PollUpdatesResponse<T>> PollUpdatesAsync<T>(string gamePlayerToken,
    string? lastUpdateId = null,
    CancellationToken ct = default)

Polls for updates from other players with optional incremental polling and typed data.

Matchmaking

GetMatchmakingLobbiesAsync
public Task<MatchmakingListResponse<T>> GetMatchmakingLobbiesAsync<T>(CancellationToken ct = default)

Lists all available matchmaking lobbies with typed rules support.

CreateMatchmakingLobbyAsync
public Task<MatchmakingCreateResponse> CreateMatchmakingLobbyAsync<T>(string gamePlayerToken,
    int maxPlayers = 4,
    bool strictFull = false,
    bool joinByRequests = false,
    T? rules = null,
    CancellationToken ct = default)

Creates a new matchmaking lobby with typed rules support and configurable settings.

RequestToJoinMatchmakingAsync
public Task<MatchmakingJoinRequestResponse> RequestToJoinMatchmakingAsync(
    string gamePlayerToken,
    string matchmakingId,
    CancellationToken ct = default)

Requests to join a matchmaking lobby that requires host approval.

RespondToJoinRequestAsync
public Task<MatchmakingPermissionResponse> RespondToJoinRequestAsync(
    string gamePlayerToken,
    string requestId,
    MatchmakingRequestAction action,
    CancellationToken ct = default)

Host responds to a join request (approve or reject).

CheckJoinRequestStatusAsync
public Task<MatchmakingRequestStatusResponse> CheckJoinRequestStatusAsync(
    string gamePlayerToken,
    string requestId,
    CancellationToken ct = default)

Checks the status of a join request.

GetCurrentMatchmakingStatusAsync
public Task<MatchmakingCurrentResponse<T>> GetCurrentMatchmakingStatusAsync<T>(string gamePlayerToken, CancellationToken ct = default)

Gets the current player's matchmaking status and lobby information with typed rules.

JoinMatchmakingDirectlyAsync
public Task<MatchmakingDirectJoinResponse> JoinMatchmakingDirectlyAsync(
    string gamePlayerToken,
    string matchmakingId,
    CancellationToken ct = default)

Joins a matchmaking lobby directly (only works if lobby doesn't require approval).

LeaveMatchmakingAsync
public Task<MatchmakingLeaveResponse> LeaveMatchmakingAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Leaves the current matchmaking lobby.

GetMatchmakingPlayersAsync
public Task<MatchmakingPlayersResponse> GetMatchmakingPlayersAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Gets all players in the current matchmaking lobby.

SendMatchmakingHeartbeatAsync
public Task<MatchmakingHeartbeatResponse> SendMatchmakingHeartbeatAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Sends heartbeat to maintain connection in matchmaking lobby.

RemoveMatchmakingLobbyAsync
public Task<MatchmakingRemoveResponse> RemoveMatchmakingLobbyAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Removes the matchmaking lobby (host only).

StartGameFromMatchmakingAsync
public Task<MatchmakingStartResponse> StartGameFromMatchmakingAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Starts a game from matchmaking lobby (host only).

Leaderboard

GetLeaderboardAsync
public Task<LeaderboardResponse<T>> GetLeaderboardAsync<T>(string[] sortBy, int limit = 10, CancellationToken ct = default)

Gets ranked leaderboard with configurable sorting, limit, and typed player data support.

Example Usage:

// Sort by level, then score
var response = await sdk.GetLeaderboardAsync<PlayerData>(
    new[] { "level", "score" }, 
    10
);

foreach (var entry in response.Leaderboard) {
    Console.WriteLine($"#{entry.Rank} - {entry.Player_name}");
    // Access typed player data: entry.PlayerData
}