Skip to main content
Retrieve groups allows you to fetch the list of groups you’ve joined and groups that are available, as well as get details for a specific group.
Available via: SDK | REST API | UI Kits

Retrieve List of Groups

In other words, as a logged-in user, how do I retrieve the list of groups I’ve joined and groups that are available? In order to fetch the list of groups, you can use the GroupsRequest class. To use this class i.e to create an object of the GroupsRequest class, you need to use the GroupsRequestBuilder class. The GroupsRequestBuilder class allows you to set the parameters based on which the groups are to be fetched. Use GroupsRequestBuilder to fetch groups with filtering, searching, and pagination.

GroupsRequestBuilder

Set Limit

Sets the number of groups to fetch per request.

Set Search Keyword

Filters groups by a search string.

Joined Only

When true, returns only groups the logged-in user has joined or is a part of.

Set Tags

Filters groups by specified tags. The list fetched will only contain the groups that have been tagged with the specified tags.

With Tags

When true, includes tag data in the returned group objects.
Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the GroupsRequest class. Once you have the object of the GroupsRequest class, you need to call the fetchNext() method. Calling this method will return a list of Group objects containing ‘n’ number of groups depending on the limit set. The list of groups fetched will only have the public and password type groups. The private groups will only be available if the user is a member of that private group.
On Success — A List<Group> containing the fetched groups. Each Group object has the following structure:Group Object:

Retrieve Particular Group Details

In other words, as a logged-in user, how do I retrieve information for a specific group? To get the information of a group, you can use the getGroup() method.
On success, the Group object containing the details of the group is returned.
On Success — A Group object containing all details of the requested group:Group Object:

Get online group member count

To get the total count of online users in particular groups, you can use the getOnlineGroupMemberCount() method.
This method returns a Map with the GUID of the group as the key and the online member count for that group as the value.
On Success — A Map<String, int> containing the GUID of each group as the key and the online member count as the value:Map Object:

Next Steps

Create Group

Create new public, private, or password-protected groups

Retrieve Members

Get the list of members in a group