The + Steam variant adds STEAM.md (steamworks4j ticket-minting guide). Valve's proprietary Steamworks SDK is a separate download from partner.steamgames.com.
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.
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.
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).
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.
public static PlayerListResponse getAllPlayers(
Client client
) throws IOException
Retrieves a list of all players (requires private API token).
public static PlayerHeartbeatResponse sendPlayerHeartbeat(
Client client,
String playerToken
) throws IOException
Updates player heartbeat to maintain online status. Call every 30-60 seconds.
public static PlayerLogoutResponse logoutPlayer(
Client client,
String playerToken
) throws IOException
Logs out a player and updates their last logout timestamp.
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.
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.
public static PlayerUnbanResponse unbanPlayer(
Client client,
int playerId
) throws IOException
Unbans a previously banned player. Requires private API token.
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".
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.
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.
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).
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.
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.
public static SteamFriendsLookupResponse lookupSteamFriends(Client client, String playerToken, List<String> steamIds) throws IOException
Maps SteamID64s to registered players — the Steam friend import list.
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.
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.
public static <T> GameDataResponse<T> getGameData(
Client client,
Class<T> dataType
) throws IOException
Retrieves global game data with Jackson compatible nested objects.
public static SuccessResponse updateGameData(
Client client,
Object data
) throws IOException
Updates global game data (requires private API token). Uses generic type for type safety.
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.
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.
public static ServerTimeResponse getServerTime(
Client client
) throws IOException
Retrieves current server time in multiple formats including UTC timestamp.
public static ServerTimeWithOffsetResponse getServerTimeWithOffset(
Client client,
int utcOffset
) throws IOException
Retrieves server time with specified UTC offset adjustment.
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.
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).
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.
public static RoomLeaveResponse leaveRoom(
Client client,
String playerToken
) throws IOException
Leaves the current game room.
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.
public static HeartbeatResponse sendRoomHeartbeat(
Client client,
String playerToken
) throws IOException
Sends heartbeat to maintain connection in game room.
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.
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.
public static RoomKickResponse kickPlayer(
Client client,
String playerToken,
int playerId
) throws IOException
Kicks a player from the game room (Host Only). Cannot kick yourself.
public static SuccessResponse updateRoomPassword(
Client client,
String playerToken,
String password
) throws IOException
Updates the room password (Host Only). Use empty string to remove password.
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.
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.
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.
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.
public static UpdatePlayersResponse updatePlayers(
Client client,
String playerToken,
UpdatePlayers<?> request
) throws IOException
Sends updates to specific players or all players. Uses typed UpdatePlayers parameter.
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.
Reliable WebSocket (TCP) plus an optional UDP fast lane — 1 TCP + 1 UDP per player
public static TokenResponse getToken(
Client client,
String playerToken
) throws IOException
Retrieves a realtime authentication token for WebSocket connections.
public boolean connect(
String realtimeToken
)
Connects to the realtime WebSocket server using the provided token.
public void send(
ERoomTargetPlayer target,
String command,
Object data,
int[] targetIds
)
Sends a message to the specified players via WebSocket.
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.
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.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.
public void disconnect()
Disconnects from the server and cleans up both channels.
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.
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.
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).
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).
public static MatchmakingPermissionResponse respondToJoinRequest(
Client client,
String playerToken,
String requestId,
EMatchmakingRequestAction action
) throws IOException
Responds to a join request (APPROVE or REJECT). Host only.
public static <T> MatchmakingCurrentResponse<T> getCurrentMatchmakingStatus(
Client client,
String playerToken,
Class<T> rulesType
) throws IOException
Gets current matchmaking lobby status with typed rules support.
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.
public static MatchmakingStartResponse startGameFromMatchmaking(
Client client,
String playerToken
) throws IOException
Starts the game from matchmaking lobby and creates a room. Host only.
public static MatchmakingLeaveResponse leaveMatchmaking(
Client client,
String playerToken
) throws IOException
Leaves the current matchmaking lobby.
public static MatchmakingHeartbeatResponse sendMatchmakingHeartbeat(
Client client,
String playerToken
) throws IOException
Sends heartbeat to maintain connection in matchmaking lobby.
public static MatchmakingRemoveResponse removeMatchmakingLobby(
Client client,
String playerToken
) throws IOException
Removes the matchmaking lobby (Host Only).
public static SuccessResponse stopMatchmaking(
Client client,
String playerToken
) throws IOException
Stops the matchmaking lobby before it has been started (Host Only).
public static MatchmakingKickResponse kickPlayer(
Client client,
String playerToken,
int playerId
) throws IOException
Kicks a player from the matchmaking lobby (Host Only).
public static SuccessResponse updateMatchmakingPassword(
Client client,
String playerToken,
String password
) throws IOException
Updates the matchmaking lobby password (Host Only).
public static MatchmakingRequestStatusResponse checkJoinRequestStatus(
Client client,
String playerToken,
String requestId
) throws IOException
Checks the status of a specific join request.
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.