Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Getting Started

Edward Smale edited this page Apr 8, 2020 · 2 revisions

Installing the library

You can install the library using npm, npm install --save node-smhw-client

Importing the library

You can import the library using require()

const ShowMyHomework = require("node-smhw-client")

Initialising the client

To initialise the client, you must use the Client constructor.

const Client = new ShowMyHomework.Client();

You can login using Client.login()

Client.login(<school id>, <username>, <password>).then(function () {
	// do things
});

If you don't know your school's ID. you can use the Client.searchSchools function to find your school.

Client.searchSchools("Elk Valley Elementary").then(function (school) {
	// use school[0].id to get the ID.
});

Examples

Getting all tasks for tomorrow

const ShowMyHomework = require("node-smhw-client");

const Client = new ShowMyHomework.Client();

Client.searchSchools("Elk Valley Elementary").then(function (school) {
	Client.login(school[0].id, "biglad1@biglads.com", "password").then(function () {
		Client.getTodo().then(function (tasks) {
			var tasks_for_tomorrow = tasks.filter(function (task) {
				var today = new Date();
				var tomorrow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
				var task_due = new Date(task.due_timestamp);
				
				return tomorrow.getFullYear() == task_due.getFullYear() && tomorrow.getMonth() == task_due.getMonth() && tomorrow.getDate() == task_due.getDate();
			});
			
			console.log(tasks_for_tomorrow); // Array of Task objects
		});
	});
});

Getting yours or teachers comments on homework

Client.getHomework("homework id").then(function (homework) {
	homework.getOwnSubmission().then(function (submission) {
		submission.getComments().then(function (comments) {
			console.log(comments); // Array of SubmissionComment objects
		});
	});
});

Getting your spelling test submission answers

Client.getSpellingTest("spelling test id").then(function (spelling_test) {
	spelling_test.getOwnSubmission().then(function (submission) {
		submission.getSubmissionTasks().then(function (tasks) {
			console.log(tasks.map(_ => _.attempt1.text));
		});
	});
});

Clone this wiki locally