Member query APIs return paginated or live collection results depending on the platform. Use pagination controls for large communities.
Parameters
Common Parameters
| Parameter | Description |
|---|---|
communityId | Community to query. |
roles | Optional role IDs to include, such as community-moderator. |
includeDeleted | Include deleted users when supported. |
excludingRoles | Exclude members with any role in the list. Available in TypeScript, iOS, and Android. |
limit / pagination token | Page-size and pagination controls where supported. |
Query Filters
| Platform | Values |
|---|---|
| TypeScript | memberships: ["member"], ["banned"], or omit memberships for all results |
| iOS | AmityCommunityMembership.QueryFilter.member, .banned, .all |
| Android | AmityCommunityMembershipFilter.MEMBER, BANNED, ALL |
| Flutter | AmityCommunityMembershipFilter.MEMBER, BANNED, ALL |
Query Sort Options
| Platform | Values |
|---|---|
| TypeScript | "firstCreated", "lastCreated" |
| iOS | .displayName, .firstCreated, .lastCreated, .lastJoin |
| Android | DISPLAY_NAME, FIRST_CREATED, LAST_CREATED, LAST_JOIN |
| Flutter | FIRST_CREATED, LAST_CREATED |
let communityMembership = AmityCommunityMembership(communityId: communityId)
let liveCollection = communityMembership.getMembers(
filter: .member,
roles: ["community-moderator"],
sortBy: .firstCreated,
includeDeleted: false,
excludingRoles: ["channel-moderator"]
)
token = liveCollection.observe { collection, error in
if let error = error {
handleError(error)
return
}
let members = collection.snapshots
// Render members
}
fun queryCommunityMembers(communityRepository: AmityCommunityRepository) {
communityRepository
.membership(communityId = "communityId")
.getMembers()
.filter(filter = AmityCommunityMembershipFilter.MEMBER)
.roles(roles = listOf("community-moderator"))
.excludingRoles(excludingRoles = listOf("channel-moderator"))
.includeDeleted(includeDeleted = false)
.sortBy(sortBy = AmityCommunityMembershipSortOption.FIRST_CREATED)
.build()
.query()
.doOnNext { members: PagingData<AmityCommunityMember> ->
// Render members
}
.doOnError { throwable ->
// Handle error
}
.subscribe()
}
import { CommunityRepository } from '@amityco/ts-sdk';
let nextPageFn: (() => void) | undefined;
let hasMore = false;
const unsubscriber = CommunityRepository.Membership.getMembers(
{
communityId,
memberships: ['member'],
roles: ['community-moderator'],
excludingRoles: ['channel-moderator'],
sortBy: 'firstCreated',
includeDeleted: false,
limit: 20,
},
({ data: members, onNextPage, hasNextPage, loading, error }) => {
if (error) {
// Handle error
return;
}
if (!loading && members) {
// Render members
}
hasMore = hasNextPage;
nextPageFn = onNextPage;
},
);
function loadMoreMembers() {
if (hasMore) nextPageFn?.();
}
final members = <AmityCommunityMember>[];
late PagingController<AmityCommunityMember> membersController;
void queryCommunityMembers(String communityId) {
membersController = PagingController(
pageFuture: (token) => AmitySocialClient.newCommunityRepository()
.membership(communityId)
.getMembers()
.filter(AmityCommunityMembershipFilter.MEMBER)
.roles(['community-moderator'])
.includeDeleted(false)
.sortBy(AmityCommunityMembershipSortOption.FIRST_CREATED)
.getPagingData(token: token, limit: 20),
pageSize: 20,
)..addListener(() {
if (membersController.error == null) {
members
..clear()
..addAll(membersController.loadedItems);
} else {
// Handle pagination error
}
});
}
Search Community Members
Search APIs use the same community and role controls, plus a keyword/display-name search input.Search Filters
| Platform | Values |
|---|---|
| TypeScript | memberships: ["member"], ["banned"], or omit memberships |
| iOS | AmityCommunityMembership.SearchFilter.member, .banned |
| Android | AmityCommunityMembership.MEMBER, BANNED |
| Flutter | AmityCommunityMembershipFilter.MEMBER, BANNED, ALL |
Search Sort Options
| Platform | Values |
|---|---|
| TypeScript | "displayName", "firstCreated", "lastCreated" |
| iOS | .displayName, .firstCreated, .lastCreated, .lastJoin |
| Android | DISPLAY_NAME, FIRST_CREATED, LAST_CREATED, LAST_JOIN |
| Flutter | FIRST_CREATED, LAST_CREATED |
let communityMembership = AmityCommunityMembership(communityId: communityId)
let liveCollection = communityMembership.searchMembers(
keyword: "alex",
filter: [.member],
roles: ["community-moderator"],
sortBy: .displayName,
includeDeleted: false,
excludingRoles: ["channel-moderator"]
)
token = liveCollection.observe { collection, error in
if let error = error {
handleError(error)
return
}
let members = collection.snapshots
// Render matching members
}
fun searchCommunityMembers(
communityRepository: AmityCommunityRepository,
keyword: String
) {
communityRepository
.membership(communityId = "communityId")
.searchMembers(keyword = keyword)
.roles(roles = listOf("community-moderator"))
.membershipFilter(
communityMembership = listOf(AmityCommunityMembership.MEMBER)
)
.excludingRoles(excludingRoles = listOf("channel-moderator"))
.includeDeleted(includeDeleted = false)
.sortBy(AmityCommunityMembershipSortOption.DISPLAY_NAME)
.build()
.query()
.doOnNext { members: PagingData<AmityCommunityMember> ->
// Render matching members
}
.subscribe()
}
import { CommunityRepository } from '@amityco/ts-sdk';
function searchCommunityMembers(keyword: string) {
return CommunityRepository.Membership.searchMembers(
{
communityId,
search: keyword,
memberships: ['member'],
roles: ['community-moderator'],
excludingRoles: ['channel-moderator'],
sortBy: 'displayName',
includeDeleted: false,
limit: 20,
},
({ data: members, loading, error }) => {
if (error) {
// Handle error
return;
}
if (!loading && members) {
// Render matching members
}
},
);
}
final searchResults = <AmityCommunityMember>[];
late PagingController<AmityCommunityMember> searchController;
void searchCommunityMembers(String communityId, String keyword) {
searchController = PagingController(
pageFuture: (token) => AmitySocialClient.newCommunityRepository()
.membership(communityId)
.searchMembers(keyword)
.filter(AmityCommunityMembershipFilter.MEMBER)
.roles(['community-moderator'])
.includeDeleted(false)
.sortBy(AmityCommunityMembershipSortOption.FIRST_CREATED)
.getPagingData(token: token, limit: 20),
pageSize: 20,
)..addListener(() {
if (searchController.error == null) {
searchResults
..clear()
..addAll(searchController.loadedItems);
} else {
// Handle pagination error
}
});
}
Excluding Roles
UseexcludingRoles when you need a member list that removes users with any role in the exclusion list. This filter is available in TypeScript, iOS, and Android. The current Flutter member query builder does not expose excludingRoles.
import { CommunityRepository } from '@amityco/ts-sdk';
const unsubscriber = CommunityRepository.Membership.getMembers(
{
communityId,
excludingRoles: ['community-moderator', 'channel-moderator'],
limit: 20,
},
({ data: members }) => {
// Members do not include users with excluded roles
},
);
let communityMembership = AmityCommunityMembership(communityId: communityId)
let liveCollection = communityMembership.getMembers(
filter: .member,
roles: [],
sortBy: .firstCreated,
includeDeleted: false,
excludingRoles: ["community-moderator", "channel-moderator"]
)
token = liveCollection.observe { collection, error in
let members = collection.snapshots
// Members do not include users with excluded roles
}
fun queryMembersExcludingRoles(communityRepository: AmityCommunityRepository) {
communityRepository
.membership(communityId = "communityId")
.getMembers()
.filter(filter = AmityCommunityMembershipFilter.MEMBER)
.excludingRoles(
excludingRoles = listOf("community-moderator", "channel-moderator")
)
.build()
.query()
.doOnNext { members: PagingData<AmityCommunityMember> ->
// Members do not include users with excluded roles
}
.subscribe()
}
Related Topics
Join / Leave Community
Manage joining and leaving communities.
Member Management
Add and remove community members.
Community Moderation
Manage roles, bans, and permissions.
Roles & Permissions
Understand role-based access control.