please select

Get Conversations

Description

The Chat SDK provides an API for getting conversations, which can be used to get the Conversation object information of one or multiple specified conversations.

Getting the Conversation List

Caution
1. The profile in the conversation list obtained through this API is incomplete (it only includes profile photo, nickname, etc., which is sufficient to render the conversation list). To query detailed conversation profiles, refer to getConversationProfile.
2. By default, the client can pull 100 recent conversations from the cloud. After upgrading to the Advanced Version, up to 500 recent conversations can be pulled from the cloud. The retention period of a conversation is the same as that of the last message, which is seven days by default. Please see Billing Instructions.
3. The retention period of a conversation is the same as that of the last message, which is seven days by default.
API
chat.getConversationList(options);
Parameters
Name
Type
Description
options
undefined | Array
Parameter options.
If options are not passed, it means all conversations are retrieved
If a non-empty array parameter is passed in, it indicates to get multiple specified conversations
Return values
Promise
Example
// Get the full conversation list
let promise = chat.getConversationList();
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList; // Full list of conversations, overwrite the original list
}).catch(function(imError) {
console.warn('getConversationList error:', imError); // Failed to obtain the conversation list
});
// Get the list of specified conversations
let promise = chat.getConversationList([conversationID1, conversationID2]);
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList; // List of specified conversations that exist in the cache
}).catch(function(imError) {
console.warn('getConversationList error:', imError); // Failed to obtain the conversation list
});

Getting the Session Details

API
chat.getConversationProfile(conversationID);
Parameters
Name
Type
Description
conversationID
String
Conversation ID.
Conversation ID formation method:
C2C${userID} (Private chat)
GROUP{groupID}(Group Chat)
@TIM#SYSTEM (System Notification Session)
Return values
Promise
Example
let promise = chat.getConversationProfile(conversationID);
promise.then(function(imResponse) {
// Obtained successfully
console.log(imResponse.data.conversation); // Conversation profile
}).catch(function(imError) {
console.warn('getConversationProfile error:', imError); // Failed to obtain the conversation profile
});