Canvas API Quickstart Guide for Instructors

The Canvas website is designed for human interaction, with visual elements to facilitate ease of use. The Canvas API however allows you to access the underlying data directly for use with other systems. You can use the API to do many things, such as streamline grading, access course rosters, and manage assignments.

This article outlines the steps required to access and utilize the Canvas API. For a general introduction to APIs and a detailed walk-through of using the Canvas API and its functions, please see this Canvas Developers Group article.

Generating Your Canvas Access Token

To interact with the API, you’ll need an access token, a unique string (like a password) which acts as the secure access credential for your Canvas data.

  1. Log into Canvas: Navigate to https://jhu.instructure.com/ and log in with your credentials.
  2. Access Your Account Settings: Click the Account link in the left-side navigation menu and proceed to Settings.
    Canvas user user menu showing Settings option
  3. Generate a New Token:
    • Scroll down to the Approved Integration section and click + New Access Token.
      List of Approved Integrations with New Access Token Button
    • Provide a descriptive purpose (e.g., "Research Project Automation").
    • Assign an expiration date for additional security.
    • Click Generate Token and copy the result.
      Modal for New Integration with fields filled with name and date

      Modal for the new integration showing the generated token

Important: Do not share your token publicly or with unauthorized third parties. If the token is compromised, delete it immediately using the settings menu.
List item for the example application showing the trash bin icon to delete

Making Your First API Call With Curl

Now that you have a token, let’s explore how to use it. The following example demonstrates making a simple API call to retrieve profile details associated with your Canvas account.

  1. Open the appropriate terminal application for your operating system:
    • Mac users: Open the Terminal app by searching for it via Spotlight.
    • Windows users: Use Command Prompt. (Windows users may first need to install Git for Curl to run properly. Users of current versions of Windows 10 and 11 should already have Curl installed.)
  2. Enter the Curl Command: curl https://jhu.instructure.com/api/v1/users/self -H "Authorization: Bearer $token"

    Replace "$token" with the access token generated earlier.

  3. Review the Response: After executing the command, you should receive a JSON response similar to this:
{"id":12345,"name":"Example Name","created_at":"1975-11-15T14:58:54-05:00",
"sortable_name":"Name, Example","short_name":"Example Name","pronouns":
"He/Him/His","avatar_url":"https://jhu.instructure.com/images/messages/avatar-50.png",
"last_name":"Name","first_name":"Example","locale":null,"effective_locale":"en",
"permissions":{"can_update_name":false,"can_update_avatar":true,
"limit_parent_app_web_access":false}}

Now that you have successfully queried the Canvas API and received a response to confirm that your credentials and access are functioning, you are now ready to start using your token for your project.

What data this token makes available to you is dependent upon your Canvas user account's permissions and enrollments. For faculty, you will be able to interact with courses where you have the "Instructor" role. You can use the API to create a comprehensive list of these enrollments with the commands outlined here: Canvas API documentation for the 'List your courses' function

Additional Resources

Was this article helpful?
0 out of 0 found this helpful