Options
All
  • Public
  • Public/Protected
  • All
Menu

Agora Chat SDK API Reference - v1.3.1

Chat SDK for WEB

The Agora Chat Web SDK provides a JavaScript and Typescript library.

CHATSDK is the SDK to import which contains the entire SDK.

CONNECTION is the class to instantiate.

Method Description
open Logs in.
registerUser Registers a user.
isOpened Checks the connection status. - true: Connected; - false: Not connected.
renewToken Updates token.
send Sends message.
addEventHandler Registers the listener function.
removeEventHandler Removes the listener function.
Event Description
onConnected Occurs when connecting successful. |
onReconnecting Occurs when reconnecting. |
onDisconnected Occurs when connection closed.
onError Occurs when error.
onMultiDeviceEvent Occurs when operating on multiple devices
onOffline Occurs when the network is disconnected.
onOnline Occurs when the network connection is successful.
onTokenWillExpire Occurs when the token is about to expire.
onTokenExpired Occurs when the token has expired.

CHATROOM APIS contains APIs for chatroom-related operations.

Method Description
joinChatRoom Joins the chat room.
leaveChatRoom Exits the chat room.
getChatRooms Gets the chat room list with pagination.
listChatRoomMembers Lists all chat room members with pagination.
modifyChatRoom Modifies the specifications of the chat room.
fetchChatRoomAnnouncement Gets the announcement of the chat room.
updateChatRoomAnnouncement Updates the announcement of the chat room.
setChatRoomAdmin Sets a member as the chat room admin. Only the chat room owner can call this method.
removeChatRoomAdmin Removes chat room admins. Only the chat room owner can call this method.
getChatRoomAdmin Gets all admins of the chat room.
blockChatRoomMember Adds a member to the chat room block list. Only the chat room owner or admin can call this method.
unblockChatRoomMember Removes a member from the chat room block list. Only the chat room owner or admin can call this method.
blockChatRoomMembers Adds members to the chat room block list. Only the chat room owner or admin can call this method.
unblockChatRoomMembers Removes members from the chat room block list. Only the chat room owner or admin can call this method.
getChatRoomBlocklist Gets the block list of the chat room.
muteChatRoomMember Mutes chat room member. Only the chat room owner can call this method.
unmuteChatRoomMember Unmutes the chat room member. Only the chat room owner can call this method.
disableSendChatRoomMsg Mutes all the members in the chat room. Only the chat room owner or admin can call this method.
enableSendChatRoomMsg Unmutes all the members in the chat room. Only the chat room owner or admin can call this method.
getChatRoomMutelist Gets all muted members in the chat room.
addUsersToChatRoomAllowlist Adds members to the allow list of the chat room. Only the chat room owner or admin can call this method.
removeChatRoomAllowlistMember Removes members from the allow list of the chat room. Only the chat room owner or admin can call this method.
isInChatRoomAllowlist Checks whether chat room members are on the allow list. Only the chat room owner or admin can call this method. The chat room members can check themselves.
getChatRoomAllowlist Gets the allow list of the chat room. Only the chat room owner or admin can call this method.
setChatRoomAttribute Sets a chat room custom attribute.
setChatRoomAttributes Sets the chat room attributes in batches.
removeChatRoomAttribute Removes a chat room attribute.
removeChatRoomAttributes Removes chat room custom attributes.
getChatRoomAttributes Gets all of the chat room custom
attributes.
getJoinedChatRooms Gets the list of chat rooms that a user has joined.
Event Description
onChatroomEvent Occurs when a chat room event occurs.

CONTACT APIS contains the APIs for contact-related operations.

Method Description
addContact Adds a friend.
deleteContact Deletes the contact.
declineContactInvite Declines a friend request.
acceptContactInvite Accepts a friend request.
getContacts Gets the contact list.
addUsersToBlocklist Adds a contact to the block list.
removeUserFromBlocklist Removes contacts from the block list.
getBlocklist Gets the block list.
fetchUserInfoById Queries the user attributes.
updateUserInfo Modifies the user's attributes.
deleteConversation Deletes the conversation.
getHistoryMessages Gets the message history.
addReaction Adds a reaction to the message.
deleteReaction Removes a reaction from a message.
getReactionlist Gets the reaction list for the message.
getReactionDetail Gets the details of a reaction.
getServerConversations Gets the list of conversations from the server with pagination.
getServerPinnedConversations Get the list of pinned conversations from the server with pagination.
pinConversation Sets whether to pin a conversation.
setContactRemark Set contact remark.
getAllContacts Gets the all contacts.
getContactsWithCursor Gets the list of contacts with pagination.
addConversationMark Marks conversations.
removeConversationMark Unmarks conversations.
getServerConversationsByFilter Gets the conversations from the server with pagination according to the conversation filter.
getSelfIdsOnOtherPlatform Get the unique IDs of current user on the other devices.
deleteAllMessagesAndConversations Deletes all conversations and all messages in them.
pinMessage Pins a message.
unpinMessage Unpins a message.
getServerPinnedMessages Gets the pinned messages in a conversation with pagination.
Event Description
onContactInvited Occurs when a friend request is received.
onContactAgreed Occurs when a friend request is accepted.
onContactRefuse Occurs when a friend request is rejected.
onContactAdded Occurs after adding a friend successfully.
onContactDeleted occurs after deleting a friend successfully.
onReactionChange Occurs when the reaction to a message changes.

EVENTHANDLER is the module of the SDK that is responsible for registering listening events.

Method Description
addEventHandler Adds listening events.
removeEventHandler Removes listening events.

GROUP APIS contains APIs for group-related operations.

Method Description
joinGroup Applies to join the group.
acceptGroupJoinRequest Accepts a group request. Only the group owner or admin can call this method.
rejectGroupJoinRequest Declines a group request. Only the group owner or admin can call this method.
inviteUsersToGroup Invites users into a group.
acceptGroupInvite Accepts a group invitation.
rejectGroupInvite Declines a group invitation.
leaveGroup Leaves the group.
getJoinedGroups Lists all the groups a user has joined.
getPublicGroups Gets public groups with pagination.
createGroup Creates a group instance.
destroyGroup Destroys a group. Only the group owner can call this method.
changeGroupOwner Transfers a group. Only the group owner can call this method.
modifyGroup Modifies group information. Only the group admin can call this method.
getGroupInfo Gets specifications of the group.
fetchGroupAnnouncement Gets the group announcement.
updateGroupAnnouncement Updates the group announcement.
getGroupAdmin Gets all admins in the group.
setGroupAdmin Sets a group admin. Only the group owner can call this method.
removeGroupAdmin Removes a group admin. Only the group owner can call this method.
blockGroupMember Adds a member to the group block list. Only the group admin can call this method.
blockGroupMembers Adds members to the group block list in bulk. Only the group admin can call this method.
unblockGroupMember Removes a member from the group block list. Only the group admin can call this method.
unblockGroupMembers Removes members from the group block list in bulk. Only the group admin can call this method.
getGroupBlocklist Gets the group block list.
muteGroupMember Mutes a group member. Only the group owner or admin can call this method.
unmuteGroupMember Unmute a group member. Only the group owner or admin can call this method.
getGroupMutelist Gets the mute list of the group.
disableSendGroupMsg Mutes all members. Only the group admin or above can call this method.
enableSendGroupMsg Unmute all members. Only the group admin or above can call this method.
addUsersToGroupAllowlist Adds members to the group allow list. Members on the allow list can still post messages even if they are muted in the group. Only the group admin or above can call this method.
removeGroupAllowlistMember Removes a member from the group allow list. Only the group admin or above can call this method.
getGroupAllowlist Gets the group allow list. Only the group admin or above can call this method.
isInGroupAllowlist Checks whether the current member is on the allow list. The app admin can check all users; app users can only check themselves.
setGroupMemberAttributes Sets custom attributes of a group member.
getGroupMemberAttributes Gets all custom attributes of a group member.
getGroupMembersAttributes Gets custom attributes of multiple group members by attribute key.
Event Description
onGroupEvent Occurs when a group event occurs.

PRESENCE APIS contains APIs for presence operations.

Method Description
publishPresence Publishes a custom presence state.
subscribePresence Subscribes to a user's presence states. If the subscription succeeds, the subscriber will receive the callback when the user's presence state changes.
unsubscribePresence Unsubscribes from a user's presence states.
getSubscribedPresencelist Uses pagination to get a list of users whose presence states you have subscribed to.
getPresenceStatus Gets the current presence state of users.
Event Description
onPresenceStatusChange Occurs when the presence state of a subscribed user changes.

SILENTMODE APIS contains APIs for silent-mode operations.

Method Description
setSilentModeForAll Set the DND Settings for the current login user.
getSilentModeForAll Get the DND Settings of the current user.
setSilentModeForConversation Set the DND of the session.
clearRemindTypeForConversation Clear the setting of offline push notification type for the session.
getSilentModeForConversation Gets the DND setting of the session.
getSilentModeForConversations Obtain the DND Settings of specified sessions in batches.
setPushPerformLanguage Set user push translation language.
getPushPerformLanguage Gets the push translation language set by the user.

THREAD APIS contains APIs for message thread operations.

Method Description
createChatThread Creates a message thread.
joinChatThread Joins a message thread.
leaveChatThread Leaves the message thread.
destroyChatThread Only the owner and admins of the group to which the message thread belongs can call this method.
changeChatThreadName Changes the message thread name.
getChatThreadMembers Gets members in the message thread with pagination.
removeChatThreadMember Removes a member from the message thread.
getJoinedChatThreads Uses the pagination to get the message threads that the current user has joined.
getChatThreads Use the pagination to get the list of message threads that the current user has joined in the specified group.
getChatThreadLastMessage Gets the last threaded reply in the specified message threads.
getChatThreadDetail Gets the details of the message thread.
Event Description
onChatThreadChange Occurs when the chat thread changes.

TRANSLATION APIS contains APIs for translation operations.

Method Description
getSupportedLanguages Gets the list of supported languages for translation.
translateMessage Translates the text.

LocalCache APIS
contains APIs for localCache operations.

Method Description
getLocalConversations Gets the local conversation list.
getLocalConversation Gets a local conversation.
removeLocalConversation Removes a local conversation.
setLocalConversationCustomField Sets the local conversation custom field.
clearConversationUnreadCount Resets the number of unread messages in a conversation to 0.

MESSAGE is the message construction module in the SDK.

Event Description
onTextMessage Occurs when a text message is received.
onAudioMessage Occurs when a audio message is received.
onVideoMessage Occurs when a video message is received.
onImageMessage Occurs when a image message is received.
onCmdMessage Occurs when a command message is received.
onCustomMessage Occurs when a custom message is received.
onFileMessage Occurs when a file message is received.
onLocationMessage Occurs when a location message is received.
onStatisticMessage Occurs when a statistics message is received.
onReceivedMessage Occurs when a receipt of a message arrives at the server.
onDeliveredMessage Occurs when a message delivery receipt is received.
onReadMessage Occurs when a message read receipt is received.
onChannelMessage Occurs when a conversation read receipt is received.
onRecallMessage Occurs when a recall message notification is received.
onModifiedMessage Occurs when the message content is modified.
onMessagePinEvent Occurs when a pin message event is received.

TYPES is the type declaration module in the SDK.

Generated using TypeDoc