Canvas LMS REST API: List groups in context (course), filter empty groups

Jump to solution
theaht123
Community Explorer

We need to get groups in a course, but we have several groups with no members, which we are not interested in. Is there a way we can get all groups with a mebers_count greater than 0.

As far as we can see there are no sorting options on endpoint /api/v1/courses/:course_id/groups.

We need to get all members, for all groups (with members), for all courses, this takes a lot of time and and our plan was to sort the groups on members_count and order them by desc. That way, as soon as the last group on the page (paginated result) we could skip the rest of the calls. But it seems like this sorting is not possible.

Any suggestions to what else we can do?

Labels (1)
0 Likes
1 Solution
igustafson
Instructure
Instructure

Hello @theaht123 
Glad to help with this. To edit the group you can follow the guide here https://canvas.instructure.com/doc/api/groups.html#method.groups.update this should give you some parameters you can follow for how to move or add new students to a group 

members[] 

An array of user ids for users you would like in the group. Users not in the group will be sent invitations. Existing group members who aren't in the list will be removed from the group.

This should add users to the group

Regards,

Ian

View solution in original post