1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-11 18:59:05 +00:00
A Node.js and Deno library for requesting information from the ClassCharts API https://classchartsapi.github.io/classcharts-api-js/
Find a file
2026-05-08 18:33:08 +01:00
.devcontainer feat: Use biomejs for formatting & linting (#42) 2023-11-29 00:03:56 +00:00
.github/workflows fix: update CI 2026-05-08 18:33:08 +01:00
.vscode feat: Use biomejs for formatting & linting (#42) 2023-11-29 00:03:56 +00:00
scripts fix: update CI 2026-05-08 18:33:08 +01:00
src fix: parent client auth 2026-05-08 18:07:26 +01:00
.envrc add nix dev shell 2026-05-08 18:07:19 +01:00
.gitattributes chore: .gitattributes 2023-09-20 11:51:39 +01:00
.gitignore add nix dev shell 2026-05-08 18:07:19 +01:00
.nojekyll chore: move docs to readme 2023-08-30 16:00:24 +01:00
biome.json chore: syntax & biome.js changes 2024-01-10 10:57:33 +00:00
CONTRIBUTING.md chore: add contributing.md 2023-09-13 22:24:12 +01:00
deno.jsonc fix: update CI 2026-05-08 18:33:08 +01:00
deno.lock fix: update CI 2026-05-08 18:33:08 +01:00
flake.lock add nix dev shell 2026-05-08 18:07:19 +01:00
flake.nix fix: update CI 2026-05-08 18:33:08 +01:00
index.html chore: tweak documentation meta description 2023-09-29 13:50:03 +01:00
LICENSE chore: add license file 2022-04-10 12:23:37 +01:00
mod.ts fix: remove import map 2023-09-24 13:36:35 +01:00
README.md docs: update min nodejs version 2024-03-27 22:23:21 +00:00

ClassCharts API JS

A Node.js and Deno wrapper for getting information from the Classcharts API.

Source   •   Issues   •   NPM   •   Deno   •   Discord   •   Library Docs   •   API Docs

Introduction

The ClassCharts API is a typescript wrapper around the ClassCharts API. It allows you to easily make requests to the ClassCharts API without having to worry about the underlying implementation of making requests.

Help

For any help with the library, please join the discord where you can ask questions and get help from the community.

Contributing

Contributions are welcome! There are lots of API endpoints which we simply do not have access to to implement, so if you have access to them, please consider contributing! If you have any questions, feel free to ask in the discord.

Installation

Requirements

  • Node.js 20 or newer
    OR
  • Deno

NPM

npm install classcharts-api

Deno

The imports in the examples are for Node.js, but can easily be substituted for Deno.

import {
  ParentClient,
  StudentClient,
} from "https://deno.land/x/classcharts_api/mod.ts";

Logging In

Before making any requests, you must login to the client. This will get you a session ID which will be used for all requests.

Student Client

import { StudentClient } from "classcharts-api";

// Date of birth MUST in the format DD/MM/YYYY
const client = new StudentClient("classchartsCode", "01/01/2000");
await client.login();

Parent Client

?> The parent client is not tested, as I do not have access to a parent account. If you experience any issues, please open an issue or PR.

import { ParentClient } from "classcharts-api";

const client = new ParentClient("username", "password");
await client.login();

Universal Methods

All the following methods can be used on both the student and parent client. Each example expects the client to be already logged in.

.getStudentInfo

const studentInfo = await client.getStudentInfo();
console.log(studentInfo);
/**
{
  success: 1,
  data: {
    user: {
      id: 2339528,
      ...
    }
  },
  meta: {
    session_id: '5vf2v7n5uk9jftrxaarrik39vk6yjm48',
    ...
  }
}
*/

.getActivity

// Dates must be in format YYYY-MM-DD
const activity = await client.getActivity({
  from: "2023-04-01",
  to: "2023-05-10",
  last_id: "12",
});
console.log(activity);

.getFullActivity

// Dates must be in format YYYY-MM-DD
const activity = await client.getFullActivity({
  from: "2023-04-01",
  to: "2023-05-10",
});
console.log(activity);

.getBehaviour

Gets behaviour for a given date range.

// Dates must be in format YYYY-MM-DD
const behaviour = await client.getBehaviour({
  from: "2023-04-01",
  to: "2023-05-10",
});
console.log(behaviour);

/**
{
  "success": 1,
  "data": {
    "timeline": [
      {
        "positive": 426,
        ...
      },
    ],
	...
  "meta": {
    "start_date": "2023-04-01T00:00:00+00:00",
    ...
  }
}
*/

.getHomeworks

Gets homeworks for a given date range.

// Dates must be in format YYYY-MM-DD
const homeworks = await client.getHomeworks({
  from: "2023-04-01",
  to: "2023-05-10",
	displayDate: 'issue_date' // Can be 'due_date' or 'issue_date'
});
console.log(homeworks);

/**
{
  success: 1,
  data: [
    {
      lesson: '7A/Pe1',
			...
		},
  ],
  meta: {
    start_date: '2023-04-01T00:00:00+00:00',
		...
  }
}

.getLessons

Gets lessons for a specific date.

// Dates must be in format YYYY-MM-DD
const lessons = await client.getLessons({
  date: "2023-04-01",
});
console.log(lessons);

/**
{
  "success": 1,
  "data": [
    {
      "teacher_name": "Mr J Doe",
      ...
		}
		...
  ],
  "meta": {
    "dates": [
      "2023-05-04"
    ],
    ...
  }
}
*/

.getBadges

Gets all earned badges.

const badges = await client.getBadges();
console.log(badges);

/**
{
  success: 1,
  data: [
    {
      id: 123,
			name: 'Big Badge',
			...
    },
		...
  ],
  meta: []
}
*/

.getAnnouncements

Gets all announcements.

const announcements = await client.getAnnouncements();
console.log(announcements);

/**
 {
  success: 1,
  data: [
    {
      id: 321453,
      title: "A big announcement",
      description: "<p>School will be closing early today!</p>",
      ...
    }
  ],
  meta: []
}
*/

.getDetentions

?> This method does not include meta in the response, since I do not have access to this endpoint to test it. If you have access to this endpoint, please open a PR to add the meta response. Thanks!

Gets all detentions.

const detentions = await client.getDetentions();
console.log(detentions);

/**
 {
    "success": 1,
    "data": [
        {
            "id": 12345678,
            "attended": "no",
            "date": "2024-03-28T00:00:00+00:00",
            ...
        }
    ],
    "meta": {
        "detention_alias_plural": "detentions"
    }
}
*/

.getAttendance

?> This method does not include meta in the response, since I do not have access to this endpoint to test it. If you have access to this endpoint, please open a PR to add the meta response. Thanks!

Gets attendance.

const attendance = await client.getAttendance();
console.log(attendance);

Parent Specific Methods

.getPupils

Gets a list of all pupils the parent has access to.

const pupils = await client.getPupils();
console.log(pupils);
/**
[
	{
		id: 123,
		name: 'John Doe',
		...
	},
	...
]
*/

.selectPupil

Selects a pupil to make subsequent requests for.

await client.selectPupil(123);

.changePassword

Changes the parent's password.

await client.changePassword("oldPassword", "newPassword");