/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Search group channels by name, URL, or several types of filters

Copy link

You can search for specific private or public group channels by using several types of search filters within GroupChannelListQuery and PublicGroupChannelListQuery classes.


Search public group channels

Copy link

A PublicGroupChannelListQuery instance provides several types of search filters such as ChannelNameContainsFilter and ChannelUrlsFilter. You can use these filters to search for specific public group channels.

The sample code below shows the query instance with ChannelNameContainsFilter, which returns a list of the current user's group channels that partially match the specified keyword in their channel names.

JavaScriptTypeScript
const params = {
  includeEmpty: true,
  channelNameContainsFilter: 'Sendbird',
};
const query = sb.groupChannel.createPublicGroupChannelListQuery(params);

const channels = await query.next();

The following shows the query instance, which returns a list of the current user's group channels that partially match the keyword specified in ChannelUrlsFilter in the channel URLs.

JavaScriptTypeScript
const params = {
  includeEmpty: true,
  channelUrlsFilter: ['seminar', 'lecture'],
};
const query = sb.groupChannel.createPublicGroupChannelListQuery(params);

const channels = await query.next();

The following table shows all supported parameters that can be used as filters for PublicGroupChannelListQuery to search for specific channels you want to retrieve. You can use any of the parameters with the sample code above.

List of parameters

Copy link
Parameter nameTypeDescription

customTypesFilter

string

Specifies group channels with one or more specified custom types you want to retrieve.

customTypeStartsWithFilter

string

Specifies group channels with a custom type that starts with the specified value you want to retrieve.

channelNameContainsFilter

string

Specifies group channels that contain the specified value in their names you want to retrieve.

channelUrlsFilter

string

Specifies group channels with one or more specified channel URLs you want to retrieve.

superChannelFilter

enum

Specifies either super group channels or group channels you want to retrieve. Acceptable values are all, broadcast_only, exclusive_only, nonsuper, and super.

membershipFilter

enum

Specifies public group channels to retrieve based on membership. Acceptable values are ALL and JOINED. If set to ALL, retrieves both channels where the current user is and isn't a member. If set to JOINED, retrieves only channels where the current user is a member.

metaDataOrderKeyFilter

string

Specifies group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order you want to retrieve.

groupChannelUserIdsFilter

Interface

Specifies the GroupChannelUserIdsFilter interface which includes includeMode, queryType, and userIds.


Search private group channels

Copy link

A GroupChannelListQuery instance provides several types of search filters such as ChannelNameContainsFilter and ChannelUrlsFilter. You can use these filters to search for specific private group channels.

The sample code below shows the query instance with ChannelNameContainsFilter, which returns a list of the current user's group channels that partially match the specified keyword in their channel names.

JavaScriptTypeScript
const params = {
  includeEmpty: true,
  channelNameContainsFilter: 'Sendbird',
};
const query = sb.groupChannel.createMyGroupChannelListQuery(params);

const channels = await query.next();

The following shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in the ChannelUrlsFilter in the channels' URL.

JavaScriptTypeScript
const params = {
  includeEmpty: true,
  channelUrlsFilter: ['seminar', 'lecture'],
};
const query = sb.groupChannel.createMyGroupChannelListQuery(params);

const channels = await query.next();

The following table shows all supported parameters that can be used as filters for GroupChannelListQuery to search for specific channels you want to retrieve. You can use any of the parameters with the sample code above.

List of parameters

Copy link
Parameter nameTypeDescription

customTypesFilter

string

Specifies group channels with one or more specified custom types.

customTypeStartsWithFilter

string

Specifies group channels with a custom type that starts with the specified value.

channelNameContainsFilter

string

Specifies group channels that contain the specified value in their names.

channelUrlsFilter

string

Specifies group channels with the specified channel URLs.

superChannelFilter

enum

Specifies either super group channels or group channels. Acceptable values are all, broadcast_only, exclusive_only, nonsuper, and super.

publicChannelFilter

enum

Specifies either public or private group channels. Acceptable values are all, private, and public.

unreadChannelFilter

enum

Specifies group channels with one or more unread messages. Acceptable values are all and unread_message.

hiddenChannelFilter

enum

Specifies group channels with the specified hidden state and operating behavior. Acceptable values are hidden_only, hidden_allow_auto_unhide, hidden_prevent_auto_unhide, and unhidden_only.

myMemberStateFilter

enum

Specifies group channels' invitation status such as invitation accept status and invitation sent status. Acceptable values include all, invited_only, and joined_only.

nicknameContainsFilter

string

Specifies group channels with members whose nicknames contain the specified value.

metaDataOrderKeyFilter

string

Specifies group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order.


Retrieve a list of Supergroup channels using a filter

Copy link

You can retrieve a list of Supergroup channels through the GroupChannelListQuery's superChannelFilter property. A Supergroup channel is determined by the isSuper property. If the property has a value of true, the channel is a Supergroup channel.

JavaScriptTypeScript
const params = {
  superChannelFilter: SuperChannelFilter.SUPER,
};
const query = sb.groupChannel.createMyGroupChannelListQuery(params);

const channels = await query.next();