Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Retrieve specified friend profiles

Batch query detailed friendship records for a list of friend user IDs.

Copy

Query friendship records for specific user IDs. This method only returns users with whom you have an established friendship; to retrieve public profiles for strangers, see Retrieve user profiles:

Code example

import sdk, { GetSpecifiedFriendsReq, GetSpecifiedFriendsResp } from '@openimsdk/imsdk';

const request: GetSpecifiedFriendsReq = {
  friendUserIDs: ['user_a', 'user_b'],
  filterBlack: true,
};
const response: GetSpecifiedFriendsResp = await sdk.getSpecifiedFriends(request);

Parameters

ParameterTypeRequiredDescription
friendUserIDsstring[]YesList of user IDs to look up.
filterBlackbooleanYesSet to true to omit users currently present in the blocklist.

Return value

Returns a Promise that resolves to a GetSpecifiedFriendsResp object:

PropertyTypeDescription
friendsInfoIMFriend[]Array of found friendship records.

State changes after the call

The returned array might contain fewer items than requested if some user IDs are not friends. Order is not guaranteed to match the input list; map items using friendUserID. For friend event listening and complete field definitions, see Paginate friend list.