Retrieving groups

Retrieving group data

You can retrieve data about groups through cURL or one of the SDKs. Each provides a way to filter the list of groups by data associated with the group, such as title or path, or other properties in the group entity.

See Default Data Entity Types for a list of the system-defined properties for group entities. In addition, you can create group properties specific to your application.

Request

# Get a group by the group path, "employees/managers".
curl -X GET "https://api.usergrid.com/my-org/my-app/groups/employees/managers"
# Get a group by UUID.
curl -X GET "https://api.usergrid.com/my-org/my-app/groups/a407b1e7-58e8-11e1-ac46-22000a1c5a67e"
# Get group data filtering by their title.
curl -X GET "https://api.usergrid.com/my-org/my-app/groups?ql=select%20*%20where%20title%3D'Management%20Employees'"

Response

The following is an example of JSON returned by a query for a single group.

Example

// Call a DataClient method to retrieve the group data
// asynchronously. Handle the result with methods of the
// callback object created here. Some of the callback's
// methods are omitted for brevity.
dataClient.queryGroupsAsync(new QueryResultsCallback() {
// Handle the result of the query here.
@Override
public void onResponse(Query query) {
ApiResponse response = query.getResponse();
// Get the list of groups from the query response.
List<Entity> groups = response.getEntities();
if (groups.size() > 0)
{
// Loop through the groups data, doing something
// interesting for each.
} else {
// Do something if there aren't any groups.
}
}
});

This is the Usergrid.Collection method for getting group data from the data store. This method assumes a Collection instance that has been created with a Groups collection type. (Usergrid is the open source project on which these features are based.)