This script will get you started with interfacing with the Canvas API using JavaScript/Node.js
These instructions will get you a copy of the script up and running on your local machine for use with Canvas and your own API tokens. This script makes a request to the Canvas API that displays basic information about your user profile.
- Install Node 20 or greater.
- Install Git.
Not sure how to clone a repo? Check out this helpful guide first!
- Open command prompt on Mac or command line on Windows.
- Clone this repo.
git clone https://github.com/ubccapico/getting-started-with-the-canvas-api-with-node.git
- Then cd into the repo.
cd getting-started-with-the-canvas-api-with-node
- Run the installation script.
npm install
(If you seebabel-node: command not found
, you've missed this step.) - Generate Canvas API token and copy it to clipboard.
- Rename the
sample.env
file to.env
, and add your API token toCANVAS_API_TOKEN={ADD TOKEN HERE}
. - Run the script.
node index.js
. This should log your Canvas info.
Try running some other scripts. This script, for example, allows you to download all of the Canvas discussions from your course.
You can also write your own code and run it! Be mindful that the API is running on the production Canvas instance - if you want to run against the Beta or Test instance, change the URL in .env
to https://ubc.test.instructure.com/api/v1
or http://ubc.beta.instructure.com/api/v1
and regenerate your token(s) from the Beta/Test site. Students do not have access to Beta or Test, sorry!
- justin0022 - Justin Lee <justin.lee@ubc.ca>
This project is licensed under the GPL 3 License.