New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

uoft-canvas-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uoft-canvas-api

Canvas LMS API for Node

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

npm version JavaScript Style Guide tested with jest

Canvas LMS API for Node.js

Canvas API functions bundled as a NPM package for Node.js.

Getting Started

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.

Prerequisites

Installation

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.

For UofT:

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!

Example Usage

Get information about self:

const canvasAPI = require('uoft-canvas-api')

canvasAPI.getSelf()
  .then(self => console.log(self))

Get students in a course:

const { getUsersInCourse, getOptions } = require('uoft-canvas-api')

getUsersInCourse(12345, getOptions.users.enrollmentType.student) // first argument is Canvas course ID
  .then(students => console.log(students))

Contribute

Contributions are welcome and greatly appreciated!

How to contribute

  • Create an issue describing what contribution you are planning to make.
  • Fork the repo.
  • Add your contributions to the source directory (and not the src 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 existing index.js inside source, so that during the build your contribution will be included in src.
  • 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.

Hypothetical scenario for adding new feature

  • Add new file to source folder (say that the new file you want to add is getUsersWithGradeThreshold.js)
  • In the 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'
  • Run npm run build, which will build the project and output your new function into src.
  • In the 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.
  • Once you’re happy that it works, create a PR.

Authors

License

This project is licensed under the MIT License.

Keywords

canvas

FAQs

Package last updated on 19 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts