Unity (C#) SDK — Friends

Friends

Friend lists, #tag lookup, Steam friend import, and lobby/room invites

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.

GetFriendsAsync

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

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

LookupPlayerByTagAsync

public static Task<FriendLookupResponse> LookupPlayerByTagAsync(Client client, string playerToken, string playerTag, CancellationToken ct = default)

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

SendFriendRequestAsync / ByTag

public static Task<FriendStatusResponse> SendFriendRequestAsync(Client client, string playerToken, int playerId, CancellationToken ct = default)
public static Task<FriendStatusResponse> SendFriendRequestByTagAsync(Client client, string playerToken, string playerTag, CancellationToken ct = default)

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

Accept / Decline / Remove

public static Task<FriendStatusResponse> AcceptFriendRequestAsync(Client client, string playerToken, int playerId, CancellationToken ct = default)
public static Task<FriendStatusResponse> DeclineFriendRequestAsync(Client client, string playerToken, int playerId, CancellationToken ct = default)
public static Task<FriendStatusResponse> RemoveFriendAsync(Client client, string playerToken, int playerId, CancellationToken ct = default)

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

LookupSteamFriendsAsync

public static Task<SteamFriendsLookupResponse> LookupSteamFriendsAsync(Client client, string playerToken, List<string> steamIds, CancellationToken ct = default)

Maps SteamID64s (from SteamFriends.GetFriends()) to registered players — one-click "add Steam friend" list.

InviteFriendAsync / GetInvitesAsync

public static Task<FriendInviteResponse> InviteFriendAsync(Client client, string playerToken, int playerId, CancellationToken ct = default)
public static Task<FriendInvitesResponse> GetInvitesAsync(Client client, string playerToken, CancellationToken ct = default)

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

AcceptInviteAsync / DeclineInviteAsync

public static Task<FriendInviteAcceptResponse> AcceptInviteAsync<T>(Client client, string playerToken, string inviteId, T playerData = null, CancellationToken ct = default)
public static Task<FriendInviteAcceptResponse> DeclineInviteAsync(Client client, string playerToken, string inviteId, CancellationToken ct = default)

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

Steam invite flow

// Host publishes the lobby's join_token connect string as rich presence
SteamFriends.SetJoinConnectString($"mdl_{matchmakingId}_{joinToken}");
SteamFriends.OpenInviteDialog(connectString);   // Steam overlay picker

// Invitee — game running: GameRichPresenceJoinRequested callback
SteamTicket.RichPresenceJoinRequested += (inviter, connect) => JoinByConnectString(connect);
// Invitee — cold launch: "+connect <string>" launch parameter
var connect = SteamFriends.GetLaunchConnectString();

The Steam overlay invite dialog needs no Steam lobby. The connect string carries the backend join_token, so the invitee bypasses the lobby password. The overlay only attaches to builds launched under Steam — not the editor.

Tags, requests and invites

Every player gets a shareable #tag: lookup resolves it to a player id, and request sends a friend request by tag or id. Requests sit pending until the other side accepts or declines; once accepted the relationship appears in both players' lists together with presence, so you can show who is online.

Invites ride the same graph — a friend can be pulled straight into a matchmaking lobby or a room, and pending invites can be listed and answered by id. Steam-enabled games can additionally import the Steam friends list: pass SteamID64 strings and the API matches them to players who registered through Steam.

  • Poll the list on a cadence or after realtime events — not every frame; presence does not change that fast.
  • Invites reference a lobby or room, so private sessions stay out of the public browser entirely.
  • Cache a resolved tag before repeated lookups — tags stay stable for the lifetime of the player.
  • SDK methods are async Tasks — await them inside your own async methods, or continue on the main thread when the result touches scene objects. The managed HttpClient transport works in both Mono and IL2CPP builds.