Get Groups
List and look up RainMaker node groups for the signed-in user.
note
Obtain userInstance via ESPRMAuth.getLoggedInUser() after sign-in.
const authInstance = ESPRMBase.getAuthInstance();
const userInstance = await authInstance.getLoggedInUser();
What This Module Does ?
Retrieve groups the user owns or can access—paginated lists, lookup by ID, or lookup by name.
Use this when building a group picker, home/room list, or before group-level operations on a specific ESPRMGroup.
Use Manage Groups to create or mutate groups.
Expected outcome: ESPRMGroup instances (or lists) you can render or pass to share/metadata APIs.
Common Workflows
List all groups (paginated)
let allGroups = [];
let response = await userInstance.getGroups({
resultCount: 10,
withNodeList: true,
withSubGroups: true,
});
allGroups = allGroups.concat(response.groups);
while (response.hasNext) {
response = await response.fetchNext();
allGroups = allGroups.concat(response.groups);
}
Get group by ID
const group = await userInstance.getGroupById({
groupId: "group_id_123",
});
Get group by name
const group = await userInstance.getGroupByName({
groupName: "Living Room Devices",
});
Error Handling
try {
const group = await userInstance.getGroupById({ groupId });
if (!group) console.warn("Group not found");
} catch (error) {
console.error("Failed to load group:", error);
}
Best Practices
- Request
withNodeListwhen the UI shows device counts per group - Paginate for accounts with many groups
- Cache group instances briefly to avoid repeated lookups during navigation
Related Resource
- API Reference: