/ SDKs / .NET
SDKs
Chat SDKs .NET v4
Chat SDKs .NET
Chat SDKs
.NET
Version 4

Retrieve a list of users in an application

Copy link

By using an SbApplicationUserListQuery instance, you can retrieve a list of all or certain users in your Sendbird application. The LoadNextPage() method returns a list of SbUser objects which contain information on users within the application.

SbApplicationUserListQueryParams queryParams = new SbApplicationUserListQueryParams();
SbApplicationUserListQuery query = SendbirdChat.CreateApplicationUserListQuery(queryParams);

query.LoadNextPage((inUsers, inError) =>
{
    if (inError != null)
    {
        return; // Handle error.
    }
});

SbApplicationUserListQuery

Copy link

Using a number of different filters in the SbApplicationUserListQuery instance, you can retrieve a list of specific users that match the values set in the filters. Currently, the SbApplicationUserListQuery instance supports the following filters.

List of filters

Copy link
Filter property nameTypeDescription

UserIdsFilter

List<string>

Specifies the unique IDs of users you want to retrieve. Specifying the UserIdsFilter option enables this filter.

NicknameStartsWithFilter

string

Specifies the nickname of users you want to retrieve. Specifying the NicknameStartsWithFilter option enables this filter.

MetaDataKeyFilter

string

Specifies the metadata keys of users you want to retrieve. Specifying the MetaDataKeyFilter option enables this filter.

MetaDataValuesFilter

List<string>

Specifies the metadata values of users you want to retrieve. Specifying the MetaDataValuesFilter option enables this filter.

Note: We recommend you set the maximum number of user IDs in UserIds to 250. If exceeded, your query may receive HTTP 414 error indicating that the submitted request data is longer than the Sendbird server is willing to interpret.

// Retrieve specific users using the UserIdsFilter.
SbApplicationUserListQueryParams queryParams1 = new SbApplicationUserListQueryParams();
queryParams1.UserIdsFilter = new List<string> { "Harry", "Jay", "Jin" };
SbApplicationUserListQuery query1 = SendbirdChat.CreateApplicationUserListQuery(queryParams1);
query1.LoadNextPage((inUsers, inError) =>
{
    if (inError != null)
    {
        return; // Handle error.
    }
});

// Retrieve specific users using the metaDataKey and metaDataValues filter.
SbApplicationUserListQueryParams queryParams2 = new SbApplicationUserListQueryParams();
queryParams2.MetaDataKeyFilter = "hobby";
queryParams2.MetaDataValuesFilter = new List<string> { "movie", "book", "exercise" };
SbApplicationUserListQuery query2 = SendbirdChat.CreateApplicationUserListQuery(queryParams2);
query2.LoadNextPage((inUsers, inError) =>
{
    if (inError != null)
    {
        return; // Handle error.
    }
});