This is a fork of ecoledirecte.js
⚠ As of August 8, 2023, this module is no longer maintained: This means that although the module is perfectly functioning, I will not update it to comply to future EcoleDirecte API changes. The module may fail to fetch or send data. I would greatly appreciate PRs for feature requests / bug patches, as I no longer have the time to work on this project. Thank you.
Browse EcoleDirecte's private API with ED.js, an unofficial API client.
ed.js is a Promise-based module, built on TypeScript for a better IntelliSense and type-guarded features.
A2F method has only been tested with a student account. It's not guarranted to work for other types of account
This fork implements the new A2F method.
In addition with the basic credentials needed for the Session, you will need to add an object with the questions and for each one the corresponding answer.
import { Session } from "ecoledirecte.js";
// Create a new Session.
const session = new Session("identifiant", "motdepasse");
// A2F objet
const A2FParams = {
"question": "answer",
"What is your day of birth ?": "25"
// ...
};
// Bring your session to life!
const account = await session.login(A2FParams).catch(err => {
console.error("This login did not go well.");
});Warning: these examples might not work on your machine (depending on whether you're using
commonjsor ES6module)
import { Session } from "ecoledirecte.js";
// Create a new Session.
const session = new Session("identifiant", "motdepasse");
// Bring your session to life!
const account = await session.login().catch(err => {
console.error("This login did not go well.");
});
// Is it a student account?
if (!account || account.type !== "student") throw new Error("Not a student!");
// Get the homework due for a specific date as a simplified array
const homework = await account.getHomework({ dates: "2021-01-14" });
// Every piece of data from the API is reformatted (eg: base64 string are
// converted to text/HTML). The raw data remains always available as _raw
console.log(homework[2].contenuDeSeance.content.text);Events can be used to do something when something else happens, in real-time. (very specific, as you can tell)
For instance, the following will log the method and the url each time ed.js sends a request to the EcoleDirecte servers.
import { events } from "ecoledirecte.js";
events.on("request", ({ method, url }) => console.log(method, url));
// POST https://api.ecoledirecte.com/v3/login.awp
// POST https://api.ecoledirecte.com/v3/eleves/4179/timeline.awp
// ...See ecoledirecte-api-docs (unofficial docs)
| Dependency | Description |
|---|---|
| node-fetch | A light-weight module that brings window.fetch to Node.js |
| html-to-text | Converter that parses HTML and returns text. |
| ecoledirecte-api-types | Custom Module that maps the routes and types related to EcoleDirecte's API. Originally a part of ed.js |