sakai-api
v0.1.0-beta.0
Published
Unofficial Sakai API
Downloads
3
Readme
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
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