Browse SDKs · WASM
SDKsWASM

Search friends

Search the current user’s friends.

Copy

Use one non-empty keyword. Trim whitespace before submitting the search.

Parameters

ParameterTypeRequiredDescription
keywordListstring[]YesSearch keywords. Currently, only the first non-empty keyword is used.
isSearchUserIDbooleanYesWhether to match user IDs.
isSearchNicknamebooleanYesWhether to match friend nicknames.
isSearchRemarkbooleanYesWhether to match friend remarks.
const { data: friends } = await openimsdk.searchFriends({
  keywordList: [keyword.trim()],
  isSearchUserID: true,
  isSearchNickname: true,
  isSearchRemark: true,
});

After the Promise succeeds, read the SearchFriendsResultItem[] from data. Each item includes all FriendUserItem fields and an additional relationship value. See Get the friend list for friend profile fields.

Search results contain only the friends matched by the current query. Use userID to associate each result with existing friend data, and do not replace the complete friend list with the search results.