[ARCHIVED] Pull information through CanvasAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I am assisting a Professor to develop his own personal educational site outside of Canvas. The Professor I am working with wishes to pull information off of Canvas and display it in the off-site display. He is wanting to pull general information like the class list and course number, student list, and his students grades. Is it possible to pull this information from Canvas and push it to his site?
I have read and researched different forums about using Python and the git repository of canvasapi, but I am still deeply confused on how/what I am doing. Any information would help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @hjs653 ,
I'm one of the lead developers on the CanvasAPI library. It's definitely possible to grab all the information you want with CanvasAPI!
Something like this should be a good starting point:
from canvasapi import Canvas
API_URL = "" # institution base url (e.g. "https://example.instructure.com")
API_KEY = "" # access token
USER_ID = 1 # canvas ID of the user to get course information for
canvas = Canvas(API_URL, API_KEY)
user = canvas.get_user(USER_ID)
courses = user.get_courses()
for course in courses:
print("{} - {} ({})".format(course.course_code, course.name, course.id))
student_enrollments = course.get_enrollments(
type=['StudentEnrollment'],
state=['active']
)
for enrollment in student_enrollments:
print("\t{} {} {}".format(
enrollment.user.get('sortable_name'),
enrollment.grades.get('current_score'),
enrollment.grades.get('current_grade'),
))
Hopefully that gives you some ideas!
The best place to get help with CanvasAPI is to join UCF Open Source on Slack and join the #canvasapi channel. There's lots of friendly folks there willing to help you out! You could also create an issue on our GitHub.
Happy coding,
- Matt Emond
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.