Multiplayer API Logo

Multiplayer API

Java SDK for
Multiplayer Games

Java SDK

Java SDK Download

View on GitHub
Repository

The + Steam variant adds STEAM.md (steamworks4j ticket-minting guide). Valve's proprietary Steamworks SDK is a separate download from partner.steamgames.com.

Java API Documentation

Client

Constructor
public Client(
    String apiToken, 
    String apiPrivateToken, 
    String baseUrl,
    Logger logger
)

Initializes the SDK with API tokens and optional custom base URL. Uses Jackson Databind for JSON serialization.

Player Management

Players.registerPlayer
public static PlayerRegisterResponse registerPlayer(
    Client client,
    String name, 
    Object playerData
) throws IOException

Registers a new player with optional custom data. Uses generic type for player data with Jackson serialization.

Players.registerPlayerWithSteam
public static PlayerRegisterResponse registerPlayerWithSteam(
    Client client,
    String steamTicket,
    String steamIdentity,
    String name,
    Object playerData
) throws IOException

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. A ticket-only overload registerPlayerWithSteam(client, steamTicket) fills the rest with defaults. Response includes steam_id via getSteamId().

Ticket minting is out of scope for this SDK (server/tooling use): Java clients can mint via a Steamworks binding such as steamworks4j — SteamUser.getAuthTicketForWebApi(identity).

Players.authenticatePlayer
public static <T> PlayerAuthResponse<T> authenticatePlayer(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

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

Games.getAllPlayers
public static PlayerListResponse getAllPlayers(
    Client client
) throws IOException

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

Players.sendPlayerHeartbeat
public static PlayerHeartbeatResponse sendPlayerHeartbeat(
    Client client,
    String playerToken
) throws IOException

Updates player heartbeat to maintain online status. Call every 30-60 seconds.

Players.logoutPlayer
public static PlayerLogoutResponse logoutPlayer(
    Client client,
    String playerToken
) throws IOException

Logs out a player and updates their last logout timestamp.

Players.renamePlayer
public static PlayerRenameResponse renamePlayer(
    Client client,
    String playerToken,
    String newName
) throws IOException

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

Players.banPlayer
public static PlayerBanResponse banPlayer(
    Client client,
    int playerId,
    EBanTime banDuration,
    String banReason
) throws IOException

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

Players.unbanPlayer
public static PlayerUnbanResponse unbanPlayer(
    Client client,
    int playerId
) throws IOException

Unbans a previously banned player. Requires private API token.

Ban.isBanned
public static boolean isBanned(ApiResponse response)

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

Friends

Every player gets a persistent public player_tag (e.g. "#XK4B9P2R") on register/login — share it to be found. All methods take the player token, never the private API token.

Friends.getFriends
public static FriendListResponse getFriends(Client client, String playerToken) throws IOException

Lists friends plus incoming/outgoing requests — entries carry player_id, player_name, player_tag, is_online, steam_id, relationship.

Friends.lookupPlayerByTag
public static FriendLookupResponse lookupPlayerByTag(Client client, String playerToken, String playerTag) throws IOException

Finds a player by public tag ("#XXXXXXXX" — 8 chars, no vowels/0/1).

Friends.sendFriendRequest / ByTag
public static FriendStatusResponse sendFriendRequest(Client client, String playerToken, int playerId) throws IOException
public static FriendStatusResponse sendFriendRequestByTag(Client client, String playerToken, String playerTag) throws IOException

Sends a friend request — auto-accepts when the target already requested you.

Friends.accept / decline / remove
public static FriendStatusResponse acceptFriendRequest(Client client, String playerToken, int playerId) throws IOException
public static FriendStatusResponse declineFriendRequest(Client client, String playerToken, int playerId) throws IOException
public static FriendStatusResponse removeFriend(Client client, String playerToken, int playerId) throws IOException

Accept or decline an incoming request; removeFriend also cancels an outgoing one.

Friends.lookupSteamFriends
public static SteamFriendsLookupResponse lookupSteamFriends(Client client, String playerToken, List<String> steamIds) throws IOException

Maps SteamID64s to registered players — the Steam friend import list.

Friends.inviteFriend / getInvites
public static FriendInviteResponse inviteFriend(Client client, String playerToken, int playerId) throws IOException
public static FriendInvitesResponse getInvites(Client client, String playerToken) throws IOException

Invites a friend into your current lobby or room (kind: "matchmaking"/"room"), and lists pending invites received.

Friends.acceptInvite / declineInvite
public static FriendInviteAcceptResponse acceptInvite(Client client, String playerToken, String inviteId, Object playerData) throws IOException
public static FriendInviteAcceptResponse acceptInvite(Client client, String playerToken, String inviteId) throws IOException
public static FriendInviteAcceptResponse declineInvite(Client client, String playerToken, String inviteId) throws IOException

Accepting joins the lobby/room directly — the invite token bypasses password and host approval. Room invites return room_id.

Game Data

Games.getGameData
public static <T> GameDataResponse<T> getGameData(
    Client client,
    Class<T> dataType
) throws IOException

Retrieves global game data with Jackson compatible nested objects.

Games.updateGameData
public static SuccessResponse updateGameData(
    Client client,
    Object data
) throws IOException

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

Players.getPlayerData
public static <T> PlayerDataResponse<T> getPlayerData(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

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

Players.updatePlayerData
public static SuccessResponse updatePlayerData(
    Client client,
    String playerToken,
    Object data
) throws IOException

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

Time Management

Time.getServerTime
public static ServerTimeResponse getServerTime(
    Client client
) throws IOException

Retrieves current server time in multiple formats including UTC timestamp.

Time.getServerTimeWithOffset
public static ServerTimeWithOffsetResponse getServerTimeWithOffset(
    Client client,
    int utcOffset
) throws IOException

Retrieves server time with specified UTC offset adjustment.

Room Management

Rooms.createRoom
public static RoomCreateResponse createRoom(
    Client client,
    String playerToken,
    String roomName,
    int maxPlayers,
    String password,
    boolean hostSwitch,
    boolean canLeaveRoom,
    boolean realtime,
    Object playerData,
    Object rules
) throws IOException

Creates a new game room for multiplayer sessions with typed rules support, host switching, and player data. Max players: 2-16.

Rooms.getRooms
public static <T> RoomListResponse<T> getRooms(
    Client client,
    String search,
    Integer limit,
    Class<T> rulesType
) throws IOException

Retrieves a list of all available game rooms with typed rules support. Supports search and limit parameters (limit: 1-50).

Rooms.joinRoom
public static RoomJoinResponse joinRoom(
    Client client,
    String playerToken,
    String roomId,
    String password,
    Object playerData
) throws IOException

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

Rooms.leaveRoom
public static RoomLeaveResponse leaveRoom(
    Client client,
    String playerToken
) throws IOException

Leaves the current game room.

Rooms.getRoomPlayers
public static <T> RoomPlayersResponse<T> getRoomPlayers(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

Retrieves a list of all players in the current room.

Rooms.sendRoomHeartbeat
public static HeartbeatResponse sendRoomHeartbeat(
    Client client,
    String playerToken
) throws IOException

Sends heartbeat to maintain connection in game room.

Rooms.getCurrentRoom
public static <T> CurrentRoomResponse<T> getCurrentRoom(
    Client client,
    String playerToken,
    Class<T> rulesType
) throws IOException

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

Rooms.stopRoom
public static SuccessResponse stopRoom(
    Client client,
    String playerToken
) throws IOException

Stops the current game room (Host Only). Completely removes the room and all associated data.

Rooms.kickPlayer
public static RoomKickResponse kickPlayer(
    Client client,
    String playerToken,
    int playerId
) throws IOException

Kicks a player from the game room (Host Only). Cannot kick yourself.

Rooms.updateRoomPassword
public static SuccessResponse updateRoomPassword(
    Client client,
    String playerToken,
    String password
) throws IOException

Updates the room password (Host Only). Use empty string to remove password.

Room Actions

Actions.submitAction
public static ActionSubmitResponse submitAction(
    Client client,
    String playerToken,
    SubmitAction<?> request
) throws IOException

Submits a game action to specific targets (host, all, others, or specific players) with typed request data.

Actions.pollActions
public static <T> ActionPollResponse<T> pollActions(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

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

Actions.getPendingActions
public static <T> ActionPendingResponse<T> getPendingActions(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

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

Actions.completeAction
public static ActionCompleteResponse completeAction(
    Client client,
    String actionId,
    String playerToken,
    ActionComplete<?> request
) throws IOException

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

Room Updates

Updates.updatePlayers
public static UpdatePlayersResponse updatePlayers(
    Client client,
    String playerToken,
    UpdatePlayers<?> request
) throws IOException

Sends updates to specific players or all players. Uses typed UpdatePlayers parameter.

Updates.pollUpdates
public static <T> PollUpdatesResponse<T> pollUpdates(
    Client client,
    String playerToken,
    PollUpdates request,
    Class<T> dataType
) throws IOException

Polls for updates from other players. Returns list of update messages with typed data.

Realtime

Reliable WebSocket (TCP) plus an optional UDP fast lane — 1 TCP + 1 UDP per player

Realtime.getToken
public static TokenResponse getToken(
    Client client,
    String playerToken
) throws IOException

Retrieves a realtime authentication token for WebSocket connections.

Realtime.connect
public boolean connect(
    String realtimeToken
)

Connects to the realtime WebSocket server using the provided token.

Realtime.send
public void send(
    ERoomTargetPlayer target,
    String command,
    Object data,
    int[] targetIds
)

Sends a message to the specified players via WebSocket.

Realtime.connectUdp
public boolean connectUdp(
    Integer udpPort
)

Binds one UDP endpoint alongside the WebSocket (max 1 TCP + 1 UDP per player). Datagrams authenticate with the server-issued connection id. Null port = the udp_port announced by the server.

Realtime.sendUnreliable
public void sendUnreliable(
    ERoomTargetPlayer target,
    String command,
    Object data,
    int[] targetIds
)

Sends over the bound UDP channel — unordered, unacknowledged, latest-wins via seq. Ideal for 20-60Hz movement/state streams. Falls back to the WebSocket when UDP isn't bound.

Prediction helpers
Prediction.PredictionBuffer<S, I> — nextSeq() / record() / reconcile()
Prediction.SnapshotBuffer<S> — add(t, state, seq) / sample(renderTime, lerp)

Client-side movement prediction: record each input with its seq, adopt authoritative state on arrival, replay unacked inputs. SnapshotBuffer interpolates remote entities ~100ms in the past. In rooms/realtime/Prediction.java.

Realtime.disconnect
public void disconnect()

Disconnects from the server and cleans up both channels.

Matchmaking

Matchmaking.getMatchmakingLobbies
public static <T> MatchmakingListResponse<T> getMatchmakingLobbies(
    Client client,
    String search,
    Integer limit,
    Class<T> rulesType
) throws IOException

Retrieves a list of all available matchmaking lobbies with typed rules support.

Requests.createMatchmakingLobby
public static MatchmakingCreateResponse createMatchmakingLobby(
    Client client,
    String playerToken,
    String matchmakingName,
    int maxPlayers,
    boolean strictFull,
    boolean joinByRequests,
    boolean hostSwitch,
    boolean canLeaveRoom,
    boolean realtimeRoom,
    String password,
    Object playerData,
    Object rules
) throws IOException

Creates a matchmaking lobby with typed player data and rules support. Supports approval-based or direct join modes.

Matchmaking.joinMatchmakingDirectly
public static MatchmakingDirectJoinResponse joinMatchmakingDirectly(
    Client client,
    String playerToken,
    String matchmakingId,
    Object playerData
) throws IOException

Joins a matchmaking lobby directly (requires lobby to be in direct join mode).

Requests.requestToJoinMatchmaking
public static MatchmakingJoinRequestResponse requestToJoinMatchmaking(
    Client client,
    String playerToken,
    String matchmakingId,
    Object playerData
) throws IOException

Requests to join a matchmaking lobby (requires lobby to be in approval mode).

Requests.respondToJoinRequest
public static MatchmakingPermissionResponse respondToJoinRequest(
    Client client,
    String playerToken,
    String requestId,
    EMatchmakingRequestAction action
) throws IOException

Responds to a join request (APPROVE or REJECT). Host only.

Matchmaking.getCurrentMatchmakingStatus
public static <T> MatchmakingCurrentResponse<T> getCurrentMatchmakingStatus(
    Client client,
    String playerToken,
    Class<T> rulesType
) throws IOException

Gets current matchmaking lobby status with typed rules support.

Matchmaking.getMatchmakingPlayers
public static <T> MatchmakingPlayersResponse<T> getMatchmakingPlayers(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

Gets list of players in the matchmaking lobby with typed player data.

Matchmaking.startGameFromMatchmaking
public static MatchmakingStartResponse startGameFromMatchmaking(
    Client client,
    String playerToken
) throws IOException

Starts the game from matchmaking lobby and creates a room. Host only.

Matchmaking.leaveMatchmaking
public static MatchmakingLeaveResponse leaveMatchmaking(
    Client client,
    String playerToken
) throws IOException

Leaves the current matchmaking lobby.

Matchmaking.sendMatchmakingHeartbeat
public static MatchmakingHeartbeatResponse sendMatchmakingHeartbeat(
    Client client,
    String playerToken
) throws IOException

Sends heartbeat to maintain connection in matchmaking lobby.

Matchmaking.removeMatchmakingLobby
public static MatchmakingRemoveResponse removeMatchmakingLobby(
    Client client,
    String playerToken
) throws IOException

Removes the matchmaking lobby (Host Only).

Matchmaking.stopMatchmaking
public static SuccessResponse stopMatchmaking(
    Client client,
    String playerToken
) throws IOException

Stops the matchmaking lobby before it has been started (Host Only).

Matchmaking.kickPlayer
public static MatchmakingKickResponse kickPlayer(
    Client client,
    String playerToken,
    int playerId
) throws IOException

Kicks a player from the matchmaking lobby (Host Only).

Matchmaking.updateMatchmakingPassword
public static SuccessResponse updateMatchmakingPassword(
    Client client,
    String playerToken,
    String password
) throws IOException

Updates the matchmaking lobby password (Host Only).

Requests.checkJoinRequestStatus
public static MatchmakingRequestStatusResponse checkJoinRequestStatus(
    Client client,
    String playerToken,
    String requestId
) throws IOException

Checks the status of a specific join request.

Leaderboard

Leaderboard.getLeaderboard
public static <T> LeaderboardResponse<T> getLeaderboard(
    Client client,
    String[] sortBy,
    int limit,
    Class<T> dataType
) throws IOException

Retrieves leaderboard sorted by specified fields with typed player data support.