Skip to content

Canvas API dev#

See also: canvas-api

Resources and approaches to using the Canvas API.

Canvas Live API

How to, guides and tutorials#

ubccapico/getting-started-with-the-canvas-api-with-node#

Script and tutorial to get started with node/javascript.

Possibly not an approach usable within the browser - question of API token

Javascript libraries#

beardon/canvas-lms-api#

Another promise wrapper. Perhaps a bit more along the way than following. But is aging, no longer maintained by the company.

artevelde-uas/canvas-lms-api#

Simple(istic?) promise wrapper. Might be bare bones enough?

From Arevelde University (Belgium), one developer

ubccapico/node-canvas-api#

Specifically for Node.js. Appears to be more widely used. UBC is source

Exploration#

Using where-am-i as example.

uses function ou_getCsrfToken to apparently get the necessary token and then uses fetch as a basis for promise driven.

Which extracts the token from the users cookies

  function ou_getCsrfToken() {
        var csrfRegex = new RegExp('^_csrf_token=(.*)$');
        var csrf;
        var cookies = document.cookie.split(';');
        for (var i = 0; i < cookies.length; i++) {
            var cookie = cookies[i].trim();
            var match = csrfRegex.exec(cookie);
            if (match) {
                csrf = decodeURIComponent(match[1]);
                break;
            }
        }
        return csrf;
    }