#canvas #cli #http #command-line #authentication

bin+lib canvas-cli

Interact with Canvas LMS from the command line

1 unstable release

new 0.1.0 Mar 12, 2025

#1854 in Network programming

GPL-3.0+

3MB
709 lines

Build and Release Crates.io Version Crates.io License

Interact with Canvas LMS by Instructure from the command line. If your institution hosts Canvas under a *.instructure.com domain, it is very likely this will work 🚀

Features:

canvas-cli --help

Install

Crate

cargo install canvas-cli

Single Static Binary

Download from the GitHub Releases.

Nix

As a Nix flake:

{
  inputs = {
    canvas-cli.url = "github:mbund/canvas-cli";
  };
}
{
  pkgs,
  canvas-cli,
  ...
}: {
  # home-manager
  home.packages = with pkgs; [
    # ...
    canvas-cli.packages.x86_64-linux.default
  ];

  # nixos
  environment.systemPackages = with pkgs; [
    # ...
    canvas-cli.packages.x86_64-linux.default
  ];
}

Or run it directly with nix run github:mbund/canvas-cli auth.

Authenticate

Run canvas-cli auth and follow the prompts. In total, you will:

Go to your user profile settings at https://YOUR_INSTITUTION.instructure.com/profile/settings or through the UI. Go to Approved Integrations and click on + New Access Token.

Then, give your access token a reasonable name like canvas-cli and click Generate Token. You can leave the Expiration date and Expiration time blank for it to never expire, or to whatever date you feel is reasonable. Note that access tokens can be revoked at any time you want to later.

Finally, copy this Token field and paste it into canvas-cli auth when it asks. You can now close out of the dialog.

Access Token Details dialog with

$ canvas-cli auth
> Canvas Instance URL: https://osu.instructure.com
> Access token: ********
 Test query successful
Authenticated as:
  Mark Bundschuh (he / him / his)

Submit assignments

canvas-cli submit --help

Submit interactively, selecting the course and assignment from a dropdown.

canvas-cli submit upload-test.pdf

Or submit programmatically, specifying the Course ID and Assignment ID as arguments. These IDs are in the URL of the assignment on your Canvas instance.

canvas-cli submit -c 162316 -a 3936973 upload-test-1.pdf

Or just pass the URL to parse it.

canvas-cli submit -u https://osu.instructure.com/courses/183022/assignments/4598164 upload-test-1.pdf

Download files

Download one or more files from a course. Note that the list is like the Files tab on the course page, rather than any linked files under an Assignment.

canvas-cli download

Dependencies

~16–32MB
~499K SLoC