Canvas API

Canvas API

by 

| February 16, 2022 | in

Canvas is one of the biggest names in the learning management software (LMS) space. It is used by major Universities across the country, and we use it for Nebraska Dev Lab and our Advanced Continuing Education.

LMSs provide an online structure for courses and content. This online nature makes it easier to support remote learners. The LMS also provides some organization to your class, which is always good.

If you use Canvas, you will probably find its UI limiting. But Canvas does have a really good REST API for querying.

Why would you use the Canvas API? Many things in Canvas are not easily determined by looking at the Canvas UI. For example, querying student progress across all courses isn’t possible. Most of the UI is very course-centric.

The first step in querying Canvas is creating an Access Token. Go to “Account | Settings” and click “New Access Token”.

Generate an Access Token for Canvas

Once you have an access token, you can make calls. In the .NET world, you should consider using RestSharp to make these REST calls a little easier.

Install RestSharp.

dotnet add package RestSharp

Once you install RestSharp, you can make calls to Canvas. The code below will create an instance of RestClient. Then we make a call to get all accounts.

The Canvas API is pretty straightforward, but I found it had many obscure parameters. For example, if asked to sort the results based on last login, the last login time will be included in the response. But if you don’t ask to sort the data based on last login, you won’t get that data in the result.

Canvas has pretty good API documentation. Most of their calls are pretty consistent.

If you want to get all courses.

/courses

If you want to get all users in a course.

Courses/{COURSE_NUMBER}/users

Determining some things, like % done for a course is a little trickier.

/users/{USER_NUMBER}/courses?include[]=course_progress

You can achieve quite a bit with Canvas and its API. I recommend going slow and testing out the Canvas API using Postman to figure out how it works. But once you get your head around it, you’ll find it pretty rich.

author avatar
Chad Michel Senior Software Architect
Chad is a lifelong Nebraskan. He grew up in rural Nebraska and now lives in Lincoln. Chad and his wife have a son and daughter.

Related posts