# Query Members

## Query Channel Members

The ability to search for and query members within a chat channel is an essential feature for creating a seamless and engaging user experience. With social.plus Chat SDK, developers can use the query member feature to allow users to search for and retrieve member information within a channel. We will discuss how to use the query member feature of social.plus Chat SDK to enable users to search and retrieve member information within a chat channel.

Here's an explanation of the function parameter:

`filter`: A parameter accepting a filter enum, enabling filtering members with matching membership status.

* `ALL` -> Members with any membership status
* `MEMBER` -> Only active members
* `MUTED` -> Only muted members
* `BANNED` -> Only banned members

`roles` : A parameter accepting an array of roles, enabling filtering members with matching roles

`includeDeleted` : A parameter accepting a boolean value.

* `true` -> include a member whose user has been deleted
* `false` -> exclude member whose user has been deleted

{% hint style="info" %}
Channel member count value is based on all members in the channel including the members whose user has been deleted.
{% endhint %}

`sortBy` : A parameter accepting a sorting option enum

* `FIRST_CREATED` -> Sort by membership creation date ascending
* `LAST_CREATED` -> Sort by membership creation date ascending

Note: The membership creation date is the time the user joins the channel.

{% tabs %}
{% tab title="iOS" %}
All participation-related methods in a channel fall under a separate `ChannelParticipation` class.

{% embed url="<https://gist.github.com/amythee/9aff3540638a09382bddfea69cff07f7#file-channel_participation_init-swift>" %}

{% embed url="<https://gist.github.com/amythee/82a1cbe1e8d4bb5d19fe944b42d6c5c1#file-query_member-swift>" %}
{% endtab %}

{% tab title="Android" %}
All participation related methods in a channel fall under a separate `ChannelParticipation` class.

{% embed url="<https://gist.github.com/amythee/7fc18ad4ee355b166d791e3be949342d>" %}
{% endtab %}

{% tab title="JavaScript" %}
You can get a list of all members, or add `memberships`, `roles` , `search` parameters to get certain members of the channel.

```javascript
import { ChannelRepository, MemberFilter } from '@amityco/js-sdk';

let members;

const liveCollection = ChannelRepository.queryMembers({
  channelId: 'channel1',
  memberships: [MemberFilter.Member],
  roles: ['role1'],
  search: 'asd',
});

liveCollection.on('dataUpdated', newModels => {
  members = newModels;
});

liveCollection.on('dataError', error => {
  console.error(error);
});

members= liveCollection.models;
```

{% endtab %}

{% tab title="TypeScript" %}
Version 6

{% embed url="<https://gist.github.com/amythee/b8bb3bd99bb896c2afc2c91ca64378c3#file-querychannelmembers-ts>" %}

Beta (v0.0.1)

{% embed url="<https://gist.github.com/amythee/608812eeae0cec85b92770cf9db7764f#file-livechannelmembers-ts>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/c1476d8cc7e4a698c49460440b483151#file-amitychannelmembersearch-dart>" %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-sdk/chat/channels/query-members.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
