Notifications API (Draft WIP) - lolmaxz/vrc-ts GitHub Wiki
The Notifications API allows you to interact with notifications within VRChat. This includes retrieving your notifications, accepting friend requests, marking notifications as read, deleting notifications, clearing all notifications, and responding to specific notifications.
-
listNotifications
- Retrieve your notifications. -
acceptFriendRequest
- Accept a friend request. -
markNotificationAsRead
- Mark a notification as read. -
deleteNotification
- Delete a notification. -
clearAllNotifications
- Clear all notifications. -
respondToNotification
- Respond to a notification.
Retrieve your notifications.
Retrieve a list of your current notifications, with options to filter by type, control pagination, and include hidden notifications.
listNotifications(options: {
type: 'all' | NotificationType;
n?: number;
after?: string;
offset?: number;
hidden?: boolean;
}): Promise<Notification[]>
-
options
(object):-
type
(string, required):
The type of notifications to retrieve. Options include'all'
or specific notification types like'friendRequest'
,'invite'
, etc. -
n
(number, optional):
The number of notifications to retrieve. Must be between1
and100
. -
after
(string, optional):
A timestamp or special keyword like'five_minutes_ago'
to retrieve notifications after that time. -
offset
(number, optional):
The number of records to offset from the start. Must be0
or greater. -
hidden
(boolean, optional):
Iftrue
, includes hidden notifications in the results.
-
-
Promise<Notification[]>
: A promise that resolves to an array of notification objects.
// Example: Retrieve all notifications
const notifications = await vrchatApi.notificationsApi.listNotifications({
type: 'all',
n: 50,
});
console.log(notifications);
// Example: Retrieve friend request notifications
const friendRequests = await vrchatApi.notificationsApi.listNotifications({
type: 'friendRequest',
n: 10,
});
console.log(friendRequests);
Accept a friend request.
Accept a friend request by providing the notification ID of the friend request. Friend request notifications can be found using listNotifications
filtered by type 'friendRequest'
.
acceptFriendRequest(options: {
notificationId: string;
}): Promise<RequestSuccess>
-
options
(object):-
notificationId
(string, required):
The ID of the friend request notification to accept.
-
-
Promise<RequestSuccess>
: A promise that resolves to an object indicating the operation was successful.
// Example: Accept a friend request
const response = await vrchatApi.notificationsApi.acceptFriendRequest({
notificationId: 'notif_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(response); // { success: true }
Mark a notification as read.
Mark a specific notification as read by its notification ID.
markNotificationAsRead(options: {
notificationId: string;
}): Promise<Notification>
-
options
(object):-
notificationId
(string, required):
The ID of the notification to mark as read.
-
-
Promise<Notification>
: A promise that resolves to the updated notification object.
// Example: Mark a notification as read
const updatedNotification = await vrchatApi.notificationsApi.markNotificationAsRead({
notificationId: 'notif_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(updatedNotification);
Delete a notification.
Delete a specific notification by its notification ID.
deleteNotification(options: {
notificationId: string;
}): Promise<Notification>
-
options
(object):-
notificationId
(string, required):
The ID of the notification to delete.
-
-
Promise<Notification>
: A promise that resolves to the deleted notification object.
// Example: Delete a notification
const deletedNotification = await vrchatApi.notificationsApi.deleteNotification({
notificationId: 'notif_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(deletedNotification);
Clear all notifications.
Delete all notifications from your account.
clearAllNotifications(): Promise<RequestSuccess>
- No parameters
-
Promise<RequestSuccess>
: A promise that resolves to an object indicating the operation was successful.
// Example: Clear all notifications
const response = await vrchatApi.notificationsApi.clearAllNotifications();
console.log(response); // { success: true }
Respond to a notification.
Respond to a specific notification, such as group invitations or other actionable notifications. The response can include additional data like a group ID or user ID.
respondToNotification(options: {
notificationId: string;
responseType: 'Accept' | 'Reject' | 'Block';
groupId?: string;
userId?: string;
}): Promise<string>
-
options
(object):-
notificationId
(string, required):
The ID of the notification to respond to. -
responseType
(string, required):
The type of response. Valid values are'Accept'
,'Reject'
, or'Block'
. -
groupId
(string, optional):
The group ID associated with the response, if applicable. -
userId
(string, optional):
The user ID associated with the response, if applicable.
-
-
Promise<string>
: A promise that resolves to a message indicating the result of the response.
// Example: Accept a group invitation notification
const responseMessage = await vrchatApi.notificationsApi.respondToNotification({
notificationId: 'notif_abcdef12-3456-7890-abcd-ef1234567890',
responseType: 'Accept',
groupId: 'grp_abcdef12-3456-7890-abcd-ef1234567890',
});
console.log(responseMessage);
// Example: Reject a notification
const rejectResponse = await vrchatApi.notificationsApi.respondToNotification({
notificationId: 'notif_abcdef12-3456-7890-abcd-ef1234567890',
responseType: 'Reject',
});
console.log(rejectResponse);
enum NotificationType {
FriendRequest = 'friendRequest',
Invite = 'invite',
InviteResponse = 'inviteResponse',
RequestInvite = 'requestInvite',
Message = 'message',
RequestInviteResponse = 'requestInviteResponse',
Votekick = 'votetokick',
}
type Notification = {
id: string; // NotificationIdType
senderUserId: string; // UserIdType
senderUsername?: string; // Deprecated
type: NotificationType;
message: string;
details: string; // Additional details, may require parsing
receiverUserId?: string; // UserIdType
seen?: boolean;
created_at: string;
};
type RequestSuccess = {
success: boolean;
};
-
listNotifications
- Retrieve your notifications. -
acceptFriendRequest
- Accept a friend request. -
markNotificationAsRead
- Mark a notification as read. -
deleteNotification
- Delete a notification. -
clearAllNotifications
- Clear all notifications. -
respondToNotification
- Respond to a notification.