sakai-api
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-beta.0 • Public • Published

Sakai API

Unofficial wrapper for the Sakai API

Installation

$ npm install sakai-api

Authenticate

Before you can take any actions you need to be authenticated.

const SakaiAPI = require("sakai-api").default;

(async () => {
    const API = new SakaiAPI();
    await API.login({ username: "xxx", password: "xxx" });
})();

Getting announcement for a site

const SakaiAPI = require("sakai-api").default;

(async () => {
    const API = new SakaiAPI();
    await API.login({ username: "xxx", password: "xxx" });

    const siteId = "xxx"; // <---- site id
    let announcement = await API.getSiteAnnouncement(siteId);
    console.log(announcement.data);
})();

Getting assignments for a site

const SakaiAPI = require("sakai-api").default;

(async () => {
    const API = new SakaiAPI();
    await API.login({ username: "xxx", password: "xxx" });

    const siteId = "xxx"; // <---- site id
    let assignment = await API.getSiteAssignment(siteId);
    console.log(assignment.data);
})();

Error handling

Any unsuccessful action will throw an error. If you want to mitigate that you need to catch it.

const SakaiAPI = require("sakai-api").default;

(async () => {
    const API = new SakaiAPI();
    try {
        await API.login({ username: "xxx", password: "xxx" });

        const siteId = "xxx"; // <---- site id
        let assignment = await API.getSiteAssignment(siteId);
        console.log(assignment.data);
    } catch (e) {
        console.log(e)
    }
})();

API

SakaiAPI.new(config)

Initialize new SakaiAPI.

Param Type Description
config.baseUrl String Baseurl - your institution's url

SakaiAPI.login(params) => null

Returns the extracted meaning from a sentence, based on the context.

Param Type Description
params.username String Username
params.password String Password

SakaiAPI.getSiteAnnouncement(siteId) => Promise

Gets announcement for a specific site

Param Type Description
siteId String Site ID

SakaiAPI.getUserAnnouncement() => Promise

Gets all announcement for current user


SakaiAPI.getSiteAssignment(siteId) => Promise

Gets assignments for a specific site

Param Type Description
siteId String Site ID

SakaiAPI.getItemAssignment(assignmentId) => Promise

Gets an assignment

Param Type Description
assignmentId String Assignment ID

SakaiAPI.getMyAssignment() => Promise

Gets all assignments for current user


SakaiAPI.getSiteCalendar(siteId) => Promise

Gets calendar for a specific site

Param Type Description
siteId String Site ID

SakaiAPI.getMyCalendar() => Promise

Gets all calendars for current user


SakaiAPI.getEventCalendar(params) => Promise

Gets calendar event for a specific site

Param Type Description
params.siteId String Site ID
params.eventId String Event ID

SakaiAPI.getSite() => Promise

Gets sites for current user


SakaiAPI.getSiteContent(siteId)

Gets content for a specific site

Param Type Description
siteId String Site ID

SakaiAPI.getMyContent()

Gets content for current user


Readme

Keywords

Package Sidebar

Install

npm i sakai-api

Weekly Downloads

2

Version

0.1.0-beta.0

License

MIT

Unpacked Size

22.7 kB

Total Files

26

Last publish

Collaborators

  • besemuna