Friends API (Draft WIP) - lolmaxz/vrc-ts GitHub Wiki

Friends API Documentation

The Friends API allows you to manage friend relationships within VRChat. This includes listing your friends, sending friend requests, deleting friend requests, checking friend statuses, and unfriending users.


Index

  1. listFriends - List information about your friends.
  2. sendFriendRequest - Send a friend request to a user.
  3. deleteFriendRequest - Cancel an outgoing friend request.
  4. checkFriendStatus - Check the friend status with a user.
  5. unfriend - Remove a user from your friends list.

Endpoints

1. listFriends

List information about your friends.

Purpose

Retrieve a list of your friends, with options to control pagination and filter by online/offline status.

Method Signature

listFriends(options: {
  n?: number;
  offset?: number;
  offline?: boolean;
}): Promise<LimitedUserFriend[]>

Parameters

  • options (object):

    • n (number, optional):
      The number of friends to retrieve. Must be between 1 and 100. Default is 60.

    • offset (number, optional):
      The number of records to offset from the start. Must be 0 or greater.

    • offline (boolean, optional):
      If true, returns only offline friends. If false, returns only online and active friends. Default is false.

Returns

  • Promise<LimitedUserFriend[]>: A promise that resolves to an array of limited user friend objects.

Example Usage

// Example: List online friends
const onlineFriends = await vrchatApi.friendsApi.listFriends({
  n: 50,
  offline: false,
});
console.log(onlineFriends);
// Example: List offline friends
const offlineFriends = await vrchatApi.friendsApi.listFriends({
  n: 50,
  offline: true,
});
console.log(offlineFriends);

2. sendFriendRequest

Send a friend request to a user.

Purpose

Send a friend request to another user by their user ID.

Method Signature

sendFriendRequest(options: {
  userId: string;
}): Promise<Notification>

Parameters

  • options (object):

    • userId (string, required):
      The user ID of the user to whom you want to send a friend request.

Returns

  • Promise<Notification>: A promise that resolves to a notification object representing the sent friend request.

Example Usage

// Example: Send a friend request to a user
const friendRequestNotification = await vrchatApi.friendsApi.sendFriendRequest({
  userId: 'usr_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(friendRequestNotification);

3. deleteFriendRequest

Cancel an outgoing friend request.

Purpose

Delete an outgoing pending friend request to another user. To delete an incoming friend request, use the deleteNotification endpoint instead.

Method Signature

deleteFriendRequest(options: {
  userId: string;
}): Promise<RequestSuccess>

Parameters

  • options (object):

    • userId (string, required):
      The user ID of the user whose pending friend request you want to cancel.

Returns

  • Promise<RequestSuccess>: A promise that resolves to an object indicating the operation was successful.

Example Usage

// Example: Cancel an outgoing friend request
const response = await vrchatApi.friendsApi.deleteFriendRequest({
  userId: 'usr_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(response); // { success: true }

4. checkFriendStatus

Check the friend status with a user.

Purpose

Retrieve the friendship status with a given user, including whether you are friends, have an outgoing friend request, or have an incoming friend request.

Method Signature

checkFriendStatus(options: {
  userId: string;
}): Promise<FriendStatus>

Parameters

  • options (object):

    • userId (string, required):
      The user ID of the user whose friend status you want to check.

Returns

  • Promise<FriendStatus>: A promise that resolves to an object containing the friend status.

    type FriendStatus = {
      incomingRequest: boolean;
      isFriend: boolean;
      outgoingRequest: boolean;
    };

Example Usage

// Example: Check friend status with a user
const friendStatus = await vrchatApi.friendsApi.checkFriendStatus({
  userId: 'usr_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(friendStatus);
/*
{
  incomingRequest: false,
  isFriend: true,
  outgoingRequest: false,
}
*/

5. unfriend

Remove a user from your friends list.

Purpose

Unfriend a user by their user ID, removing them from your friends list.

Method Signature

unfriend(options: {
  userId: string;
}): Promise<RequestSuccess>

Parameters

  • options (object):

    • userId (string, required):
      The user ID of the user you want to unfriend.

Returns

  • Promise<RequestSuccess>: A promise that resolves to an object indicating the operation was successful.

Example Usage

// Example: Unfriend a user
const response = await vrchatApi.friendsApi.unfriend({
  userId: 'usr_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(response); // { success: true }

Additional Types and Enums

FriendStatus Type

type FriendStatus = {
  incomingRequest: boolean;
  isFriend: boolean;
  outgoingRequest: boolean;
};

RequestSuccess Type

type RequestSuccess = {
  success: boolean;
};

Endpoints:

  1. listFriends - List information about your friends.
  2. sendFriendRequest - Send a friend request to a user.
  3. deleteFriendRequest - Cancel an outgoing friend request.
  4. checkFriendStatus - Check the friend status with a user.
  5. unfriend - Remove a user from your friends list.

⚠️ **GitHub.com Fallback** ⚠️