Skip to main content

canvaslms: A CLI to Canvas LMS.

This program provides a command-line interface for Canvas. The command is canvaslms and it has several subcommands in the same style as Git. canvaslms provides output in a format useful for POSIX tools, this makes automating tasks much easier.

Getting started

Start by login to your Canvas server

pipx install canvaslms
canvaslms login

You can also use the package directly from Python. This lets scripts and other CLI tools import canvaslms and reuse the same authentication, configuration, and encrypted cache as the canvaslms command-line tool. The top-level canvaslms.canvas object is lazy-loaded, restored from the same encrypted cache as the CLI, and saved automatically at process exit.

import canvaslms

for course in canvaslms.canvas.get_courses():
    print(course.name)

Let's consider how to grade students logging into the student-shell SSH server. We store the list of students' Canvas and KTH IDs in a file.

canvaslms users -sc DD1301 | cut -f 1,2 > students.csv

Then we check who has logged into student-shell.

ssh student-shell.sys.kth.se last | cut -f 1 -d " " | sort | uniq \
  > logged-in.csv

Finally, we check who of our students logged in. We can set their grade to P and add the comment "Well done!" in Canvas. We set the grades for the two assignments whose titles match the regular expression (Preparing the terminal|The terminal).

for s in $(cut -f 2 students.csv); do
  grep $s logged-in.csv && \
    canvaslms grade -c DD1301 -a "(Preparing the terminal|The terminal)" \
      -u $(grep $s students.csv | cut -f 1) \
      -g P -m "Well done!"
done

Analyzing Quiz/Survey Results

The quizzes analyse command helps you analyze Canvas quiz or survey evaluation data. Download the Student Analysis Report CSV from Canvas and run:

# Markdown output (default, rendered with rich)
canvaslms quizzes analyse --csv survey_results.csv

# LaTeX output (for PDF compilation)
canvaslms quizzes analyse --csv survey_results.csv --format latex > report.tex

This will provide:

  • Statistical summaries for quantitative questions (ratings, multiple choice)
  • Proper handling of multi-select questions (comma-separated options)
  • All individual responses for qualitative questions (free text)
  • AI-generated summaries of qualitative responses (requires llm, install with canvaslms[llm])

If you installed with the [llm] extra, configure your API keys:

llm keys set openai  # or another provider

Managing Quiz Content

View and edit quiz content directly from the command line:

# View quiz questions rendered as markdown
canvaslms quizzes view -c "Course" -a "Quiz Name"

# Edit quiz content interactively
canvaslms quizzes edit -c "Course" -a "Quiz Name"

# Export quiz items for backup or migration
canvaslms quizzes items export -c "Course" -a "Quiz Name" --importable

# Add questions to a quiz bank (use --example to see question formats)
canvaslms quizzes items add -c "Course" -a "Quiz Name" --example

Editing Announcements and Discussions

Edit existing announcements using the same workflow as pages:

# Edit interactively (opens in editor)
canvaslms discussions edit -c "Course" -t "Announcement Title"

# Edit from a markdown file with YAML front matter
canvaslms discussions edit -c "Course" -t "Announcement Title" -f announcement.md

Installation

Install the PyPI package using pip or pipx:

# Basic installation (Python 3.10+)
python3 -m pip install canvaslms
# or
pipx install canvaslms # recommended

# With optional LLM support for AI summaries (Python 3.10+)
python3 -m pip install canvaslms[llm]
# or
pipx install canvaslms[llm] # recommended

The [llm] extra includes the llm package and various LLM provider plugins (OpenAI, Anthropic, Gemini, Azure) for AI-powered features like quiz analysis summaries.

The Python API uses the same credential sources as the command-line tool: system keyring, CANVAS_SERVER/CANVAS_TOKEN, or the config file.

Some subcommands use pandoc, so you will likely have to install pandoc on your system manually.

Development

This project uses literate programming with noweb. The source code is written in .nw files which combine documentation and code.

GitHub Copilot Setup

This repository includes GitHub Copilot configuration files:

  • .github/copilot-instructions.md: Project context and coding guidelines
  • .copilotignore: Files to exclude from Copilot context

The configuration helps Copilot understand the literate programming approach, Canvas LMS domain, and project-specific patterns.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

canvaslms-6.20.tar.gz (488.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

canvaslms-6.20-py3-none-any.whl (547.2 kB view details)

Uploaded Python 3

File details

Details for the file canvaslms-6.20.tar.gz.

File metadata

  • Download URL: canvaslms-6.20.tar.gz
  • Upload date:
  • Size: 488.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.7 Linux/6.17.0-41-generic

File hashes

Hashes for canvaslms-6.20.tar.gz
Algorithm Hash digest
SHA256 240a4f9e21d0d6eb20444f09ee51206f58e60e5c226c3acc1765fcda1e69cadc
MD5 4e670afdbd919647098730de5f822bbf
BLAKE2b-256 9804ac6cf1ed7ec41632619751d0d499f3c6cd3a62345f50fe4f89f1d6ae26e6

See more details on using hashes here.

File details

Details for the file canvaslms-6.20-py3-none-any.whl.

File metadata

  • Download URL: canvaslms-6.20-py3-none-any.whl
  • Upload date:
  • Size: 547.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.7 Linux/6.17.0-41-generic

File hashes

Hashes for canvaslms-6.20-py3-none-any.whl
Algorithm Hash digest
SHA256 13f587a018ef42be3d352c30a623b52638c23104f6af5be5d7ddedd965611ac1
MD5 20582e12eb780336975d53a595eebba6
BLAKE2b-256 4a3c14b60764362ab0115bd5fc2ba0058eadc00f63e6aded2fa9125062620edf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

6.20 This release

2 files

6.19

1 file

6.18

2 files

6.17

2 files

6.16

2 files

6.15

2 files

6.14

2 files

6.13

2 files

6.12

2 files

6.11

2 files

6.10

2 files

6.9

2 files

6.8

2 files

6.7

2 files

6.6

2 files

6.5

2 files

6.4

2 files

6.3

2 files

6.2

2 files

6.1

2 files

6.0

2 files

5.10

2 files

5.9

2 files

5.8

2 files

5.7

2 files

5.6

2 files

5.5

2 files

5.4

2 files

5.3

2 files

5.2

2 files

5.1

2 files

5.0

2 files

4.15

2 files

4.14

2 files

4.13

2 files

4.12

2 files

4.11

2 files

4.10

2 files

4.2

2 files

4.1

2 files

4.0

2 files

3.9

2 files

3.8

2 files

3.7

2 files

3.6

2 files

3.5

2 files

3.4

2 files

3.3

2 files

3.0

2 files

2.23

2 files

2.22

2 files

2.21

2 files

2.20

2 files

2.19

2 files

2.18

2 files

2.17

2 files

2.16

2 files

2.15

2 files

2.14

2 files

2.13

2 files

2.12

2 files

2.11

2 files

2.10

2 files

2.9

2 files

2.8

2 files

2.7

2 files

2.6

2 files

2.5

2 files

2.4

2 files

2.3

2 files

2.2

2 files

2.1

2 files

2.0

2 files

1.20

2 files

1.19

2 files

1.18

2 files

1.17

2 files

1.16

2 files

1.15

2 files

1.14

2 files

1.13

2 files

1.12

2 files

1.11

2 files

1.10

2 files

1.9

2 files

1.8

2 files

1.7

2 files

1.6

2 files

1.5

2 files

1.4

2 files

1.3

2 files

1.2

2 files

1.1

2 files

1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page