please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Web/
Conversation/
SDK
  • Install Chat SDK
  • Initialize Chat SDK
  • Login and Logout
  • Client APIs
  • Changelog
  • Message
    • Overview
    • Send a Message
    • Receive a Message
    • Historical Message
    • Forward Messages
    • Modify a Message
    • Delete Messages
    • Clear History Message
    • Recall a Message
    • Send an Online Message
    • Message Read Receipt
    • Query Messages
    • Targeted Group Message
    • Do not Notify
    • Key-Value Extensions
    • Translation
  • Conversation
    • Overview
    • Conversation List
    • Get Conversations
    • Unread Count
    • Pin Conversations
    • Delete Conversations
    • Mark
    • Conversation Group
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • Community Topic
    • Community Management
  • User Profile and Relationship Chain
    • User Profile
    • User Status
    • Friend Management
    • Friend Group
    • Block List
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

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
});