Access the Canvas API using Node.js. 54 functions (and counting)! Pull requests are welcome and appreciated.
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.
To use with node:
$ npm install node-canvas-api
Then, in wherever you want to use this package:
const canvasAPI = require('node-canvas-api')
Rename the sample.env
file to .env
and add your institution's domain and API access token.
Attached to the canvasAPI
are a bunch of functions.
Run the attached functions!
const canvasAPI = require('node-canvas-api')
canvasAPI.getSelf()
.then(self => console.log(self))
const { getUsersInCourse, getOptions } = require('node-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!
source
directory (and not the src
directory. This directory is generated by Rollup during the build phase, and is what gets published to npm.)source
, please add the file to the existing index.js
inside source
, so that during the build your contribution will be included in src
.src
, and running it.source
folder (say that the new file you want to add is getUsersWithGradeThreshold.js
)source
folder, there’s an index.js
file that lists all of the files you want exported to src
. There you will add: export { default as getUsersWithGradeThreshold } from './getUsersWithGradeThreshold'
npm run build
, which will build the project and output your new function into src
.index.js
at the root of the project that you create (this is not the index.js
that’s in the source
folder), import your new file from src
like this: const getUsersWithGradeThreshold = require('.src/getUsersWithGradeThreshold')
and test by running the code: node index.js
.This project is licensed under the MIT License.