Skip to main content

Canvas API Wrapper

This is a CLI wrapper around the Canvas LMS API

Installation

Installation requires Python 3.10

$ pip install canvas-api-cli
$ canvas --help

Configuration

The config file should be located at $HOME/.config/canvas.toml, and look something like this:

[instance]
default="<nickname>"

[instance.<nickname>]
domain="domain.instructure.com"
token="<API TOKEN>"

To test that it's configured properly you can execute

$ canvas get users/self

And confirm that the output is for your user

Canvas Instances

Each customer or entity that Instructure deals with is given their own Canvas instance with a unique domain name. Each instance is added to your configuration like so:

[instance.<nickname>]
domain="domain.instructure.com"
token="<API TOKEN>"

The Canvas instance to use can then be selected when running a query

$ canvas get users/self -i <nickname>

If no instance is specified then the default will be used. If the configuration does not have a default, then you must specific an instance with every query

[instance]
default="<nickname>"

[instance.<nickname>]
domain="domain.instructure.com"
token="<API TOKEN>"

Usage

You can query Canvas endpoints using the query subcommand and it's aliases (get, post, put and delete)

$ canvas get <endpoint>

The endpoint parameter will simply be the unique part of the API url. For example: The URL: https://canvas.instructure.com/api/v1/accounts/:account_id/users would be queried as

$ canvas get accounts/:account_id/users

Query Parameters

Query Parameters are added using the -q option

$ canvas get :course_id/assignments -q include[]=submission -q all_dates=true

Request Body

The request body for POST or PUT requests is passed in via the -d option

Either as a JSON string:

$ canvas put courses/:course_id/assignments/:assignment_id  -d '
     {
       "assignment": {
         "name": "New Test Name"
       }
     }
     '

Or a filename

$ canvas put courses/:course_id/assignments/:assignment_id  -d @file.json

Piping

When you pipe the output of canvas to another program, syntax highlighting will not be added. This is convenient, because it allows you to pipe to other programs like jq very easily. Additionally, any info that is not the JSON response from Canvas is written to stderr instead of stdout, so you don't have to worry abou those

The JSON output will still be formatted. If you want to disable all of that you can use the --raw flag

Metadata

Release files for canvas-api-cli 0.5.0

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

Source distribution (sdist)

Source distribution for canvas-api-cli 0.5.0
File Size Uploaded Provenance
canvas_api_cli-0.5.0.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for canvas-api-cli 0.5.0
File Interpreter ABI Platform
canvas_api_cli-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / canvas_api_cli-0.5.0.tar.gz

Download URL canvas_api_cli-0.5.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
69edd20e2d87e400378169a181f7599c17070105a0486fdf4c12aa95de3d0e6f
BLAKE2b-256 checksum
How to use checksums
10bcac0d151bae544b9c724f38d5f19a2fa574177db2b1f3b2f9feae65e7f0ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/25.5.0

Release files / canvas_api_cli-0.5.0-py3-none-any.whl

Download URL canvas_api_cli-0.5.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1348fa96d696e4c767151415fa4538e2dbec0fd085aaae5112f33e08ccb6645c
BLAKE2b-256 checksum
How to use checksums
902167411f0c17a5c632e8bc2bbec9f668d8bd1dd0afe6446651000ce3cd8cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/25.5.0

Security for canvas-api-cli 0.5.0

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.

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