Can you get the List Enrollments API call without getting user information?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi There
Is it possible to make the List Enrollments (https://canvas.instructure.com/doc/api/enrollments.html#method.enrollments_api.index) API call without receiving "user" data in the response body?
Here is an example request:
https://qwickly.instructure.com/api/v1/courses/248/enrollments?state%5B%5D=invited&state%5B%5D=activ...
Here is an example response from the listed request:
{'course_id': 248, 'id': 2165, 'user_id': 570, 'course_section_id': 266, 'root_account_id': 1, 'type': 'StudentEnrollment', 'created_at': '2021-11-19T15:37:37Z', 'updated_at': '2021-12-07T20:26:48Z', 'associated_user_id': None, 'start_at': None, 'end_at': None, 'limit_privileges_to_course_section': True, 'enrollment_state': 'active', 'role': 'StudentEnrollment', 'role_id': 3, 'last_activity_at': None, 'last_attended_at': None, 'total_activity_time': 0, 'grades': {'html_url': 'https://qwickly.instructure.com/courses/248/grades/570', 'current_grade': None, 'current_score': None, 'final_grade': None, 'final_score': None, 'unposted_current_score': None, 'unposted_current_grade': None, 'unposted_final_score': None, 'unposted_final_grade': None}, 'sis_account_id': None, 'sis_course_id': None, 'course_integration_id': None, 'sis_section_id': None, 'section_integration_id': None, 'sis_user_id': '472042', 'html_url': 'https://qwickly.instructure.com/courses/248/users/570', 'user': {'id': 570, 'name': 'David Abraham', 'created_at': '2021-11-17T09:24:57-07:00', 'sortable_name': 'Abraham, David', 'short_name': 'David Abraham', 'sis_user_id': '472042', 'integration_id': None, 'login_id': 'david.abraham@goqwickly.com'}}
Our tool is designed to load enrollments in a course, and subsequently load the data of the users individually. We want to follow a workflow where user data is not returned with each enrollment data since we may have already saved certain user data in the past and thus we can save time by not getting user data with each request.
This is causing API load time issues for clients who have common classe sizes well over 500+ users.
Ideally the enrollments call would simply return the enrollment data, course_id and user_id. We would then be able to see if we are missing any user data for any of the user_ids and make separate Get User requests to get those data pieces.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't change the structure of data returned by API. However, you can try GraphQL which allows you to select only the fields you want to pull.
The GraphQL playground is available at youracademy.instructure.com/graphiql. You can try the following query which returns all student enrollment within a course and its status
query MyQuery {
course(id: "49") {
enrollmentsConnection(filter: {types: StudentEnrollment}) {
nodes {
user {
_id
}
state
}
}
}
}
You can also post this query to the GraphQL endpoint, take a look at the document here: https://canvas.instructure.com/doc/api/file.graphql.html