Canvas API functions bundled as a NPM package for Node.js.
These instructions will get you a copy of the project up and running on your local machine for use with your own API tokens and Canvas domains.
- Install Node 8.0.0 or greater.
To use with node:
$ npm install uoft-canvas-api
Then, in wherever you want to use this package:
const canvasAPI = require('uoft-canvas-api')
Rename the sample.env
file to .env
and add your institution's domain and API access token.
CANVAS_API_TOKEN={YOUR_TOKEN_FROM_QUERCUS}
CANVAS_API_DOMAIN=https://q.utoronto.ca/api/v1
Attached to the canvasAPI
are a bunch of functions.
Run the attached functions!
const canvasAPI = require('uoft-canvas-api')
canvasAPI.getSelf()
.then(self => console.log(self))
const { getUsersInCourse, getOptions } = require('uoft-canvas-api')
getUsersInCourse(12345, getOptions.users.enrollmentType.student) // first argument is Canvas course ID
.then(students => console.log(students))
Contributions are welcome and greatly appreciated!
- Create an issue describing what contribution you are planning to make.
- Fork the repo.
- Add your contributions to the
source
directory (and not thesrc
directory. This directory is generated by Rollup during the build phase, and is what gets published to npm.) - If you add a file to
source
, please add the file to the existingindex.js
insidesource
, so that during the build your contribution will be included insrc
. - Test your code by creating a file in the root of the project directory, importing your code addition from
src
, and running it. - Once you're happy with your contribution, open an pull request and I'll take a look.
- Add new file to
source
folder (say that the new file you want to add isgetUsersWithGradeThreshold.js
) - In the
source
folder, there’s anindex.js
file that lists all of the files you want exported tosrc
. There you will add:export { default as getUsersWithGradeThreshold } from './getUsersWithGradeThreshold'
- Run
npm run build
, which will build the project and output your new function intosrc
. - In the
index.js
at the root of the project that you create (this is not theindex.js
that’s in thesource
folder), import your new file fromsrc
like this:const getUsersWithGradeThreshold = require('.src/getUsersWithGradeThreshold')
and test by running the code:node index.js
. - Once you’re happy that it works, create a PR.
- goelbenj - Benjamin Goel <benjamin.goel@mail.utoronto.ca>
This project is licensed under the MIT License.