List of users by role via API

361 views
Skip to first unread message

sim...@mst.edu

unread,
Mar 2, 2015, 4:39:18 PM3/2/15
to canvas-lms...@googlegroups.com
Looking at the API documentation you can get a list of users who are admins with:

GET /api/v1/accounts/:account_id/admins



Is there a similar way to retrieve a list of accounts with other roles?  We would like to generate a list of users who have the teacher role.  I'm having a difficulty finding such an option in the API documentation.  

Thanks,
Ryan

Battis, Seth

unread,
Mar 5, 2015, 10:45:11 AM3/5/15
to canvas-lms...@googlegroups.com
Ryan --

GET /api/v1/accounts/:account_id/admins will list all of the users who have been assigned an account-level admin role within that account. For example, I have a "Department Chair" and "Department Member" role for each of our departmental sub-accounts, and listing admins will list all of those users.

It sounds like what you really want is a listing of folks based on their course enrollments within the account. Something like "all the teachers enrolled in courses in account X". I've got a PHP script that lists teachers by term, but the general idea would be something like…

GET /api/v1/accounts/:account_id/courses

and then loop through those results, querying each course:

GET /api/v1/courses/:course_id/enrollments?type[]=TeacherEnrollment

or

GET /api/v1/courses/:course_id/enrollments?role[]=My%20Fancy%Custom%20Teacher%20Role

It _feels_ like there should be a better way, but I'm not sure that there is.


— S

Mathematics Dept. Chair • Director of Academic Technology • FIRST Team Mentor
St. Mark's School • 25 Marlboro Rd., Southborough, MA 01772 • stmarksschool.org

--
You received this message because you are subscribed to the Google Groups "Canvas LMS API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sim...@mst.edu

unread,
Mar 6, 2015, 10:33:12 AM3/6/15
to canvas-lms...@googlegroups.com
Seth,

That's a good idea (getting courses and loop through them) and gives me a place to start.  It would be nice if there was an API object to use similar to the one for Admins.  

Thanks!

Ryan
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-users+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages