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

Then let the built-in tutorials walk you through the commands against your own courses. Each step opens a shell, tells you what to type, and checks what you did; progress is saved between runs.

canvaslms tutorial list
canvaslms tutorial run getting-started

The first tutorial covers logging in and listing courses and users. Later ones cover assignments and grading, course content, and letting a coding agent such as Claude Code run canvaslms for you through the skills in dbosk/claude-skills.

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

Quizzes written elsewhere, for example with text2qti, can be imported as QTI 1.2 packages. First list your courses and their IDs, then replace 12345 below with your course ID to upload a generated Classic quiz. Run the last command after regenerating the ZIP to replace its questions. Replacing keeps the quiz's ID and settings, requires an unpublished quiz without student attempts, and writes a backup that quizzes edit -f can restore.

canvaslms courses --all --id
quiz_id=$(canvaslms quizzes import -c '^12345$' -f quiz.qti.zip --id-only)
canvaslms quizzes import -c '^12345$' -f quiz.qti.zip -a "^$quiz_id$" --replace-items

Add --type new to import as a New Quiz instead (fresh imports only), and canvaslms quizzes list -c '^12345$' -i to list quizzes with their IDs.

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 [fbf] extra installs FeedbackFruits, which adds the canvaslms fbf command for detailed FeedbackFruits data (peer reviews, grade breakdowns, discussions), fetched through the Canvas LTI launch with your canvaslms login:

pipx install canvaslms[fbf]

The fbf command appears only when the package is installed. FeedbackFruits cannot be installed together with the unrelated fbf package on PyPI, since both provide the import name fbf.

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.

Metadata

Release files for canvaslms 6.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for canvaslms 6.28
File Size Uploaded Provenance Actions
canvaslms-6.28.tar.gz 956.2 kB Without provenance Details for canvaslms-6.28.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for canvaslms 6.28
File Interpreter ABI Platform Actions
canvaslms-6.28-py3-none-any.whl Python 3 none any Details for canvaslms-6.28-py3-none-any.whl

Total release size: 1.2 MB

Release files / canvaslms-6.28.tar.gz

Download URL canvaslms-6.28.tar.gz
Size 956.2 kB
Tags Source
SHA-256 checksum
How to use checksums
df7575ea5a5bd4e815533efcf103978387e16d46adc702b5d13824ce71639c17
BLAKE2b-256 checksum
How to use checksums
35cd8523a88d20d842ca03493d73c7858cd3580a24128deee30f33fbe386afc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.4 Linux/7.0.0-42-generic

Release files / canvaslms-6.28-py3-none-any.whl

Download URL canvaslms-6.28-py3-none-any.whl
Size 232.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d035dc9031420ec3ed5a0aec0e2eec5d10d47fdf0b2bdc74fd31ca7f53d8f573
BLAKE2b-256 checksum
How to use checksums
483b3735bf03bcbe82038f3e2cd7035f5180c384806746dd8cc403b5b5e2b62b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.4 Linux/7.0.0-42-generic

Security for canvaslms 6.28

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.28 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page