@abrianto/smartschool-kit@0.0.13Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
A modern, TypeScript-based, non-opinionated client for the Smartschool's APIs. This client provides a simple interface to interact with all Smartschool API endpoints.
Smartschool API wrapper with CLI interface
A modern, TypeScript-based, non-opinionated client for the Smartschool's APIs. This client provides a simple interface to interact with all Smartschool API endpoints.
Features
- π Runtime agnostic (works in Deno, Browser, Node.js)
- πͺ Full TypeScript support with comprehensive type definitions
- π§ CLI interface for quick operations
- π― Supports all Smartschool API endpoints
- π Detailed documentation for each method
Installation
# From JSR jsr add @abrianto/smartschool-client # Direct import import { SmartschoolClient } from "jsr:@abrianto/smartschool-client";
Usage
As a Library
import { SmartschoolClient } from "@abrianto/smartschool-client"; const client = new SmartschoolClient({ apiEndpoint: "https://your-school.smartschool.be/Webservices/V3", accesscode: "your-access-code" }); // Create a user await client.saveUser({ username: "john.doe", name: "John", surname: "Doe", email: "john@example.com", basisrol: "leerkracht" }); // Send a message await client.sendMsg({ userIdentifier: "john.doe", title: "Welcome", body: "Welcome to Smartschool!", senderIdentifier: "admin" }); // Get user details const userDetails = await client.getUserDetails({ userIdentifier: "john.doe" });
Using the CLI
# Get help deno run --allow-net ./bin/cli.ts --help # Create a user, skip optional parameters deno run --allow-net ./bin/cli.ts \ --method=saveUser \ --config=./config.json \ --username=john.doe \ --name=John \ --surname=Doe \ --skip # Send a message deno run --allow-net --allow-read --allow-env ./bin/cli.ts \ --config=./config.json \ --method=sendMsg \ --userIdentifier=jane.roe \ --title=Hallo \ --body="Lorem ipsum" # Get absents deno run --allow-net --allow-read --allow-env ./bin/cli.ts \ --config=./config.json \ --method=getAbsents \ --userIdentifier=jane.roe \ --schoolYear=2025 # Interactive mode deno run --allow-net cli.ts --interactive
Available Methods
See coverage
User Management
saveUser- Create or update a usergetUserDetails- Get user detailsgetUserDetailsByNumber- Get user details by internal numbergetUserDetailsByUsername- Get user details by usernamegetUserDetailsByScannableCode- Get user details by scannable codedelUser- Delete a user (optionalofficialDate)setAccountStatus- Set user account statuschangeUsername- Change a user's usernamechangeInternNumber- Change a user's internal numberchangePasswordAtNextLogin- Force password change at next loginforcePasswordReset- Force password resetreplaceInum- Replace internal user numbersaveUserParameter- Update user parameters (e.g., co-accounts)changeGroupOwners- Update group owners
Groups and Classes
saveGroup- Create or update a groupsaveClass- Create or update a class (optionalinstituteNumber,adminNumber,schoolYearDate)getAllGroupsAndClasses- Get all groups and classesgetClassList- Get class listgetClassListJson- Get class list in JSONgetClassTeachers- Get class teachers (optionalgetAllOwners)saveUserToGroup- Add user to group (viasaveUserToClass/saveUserToClasses)removeUserFromGroup- Remove user from group (optionalofficialDate)delClass- Delete a classsaveClassList- Bulk update class list (serialized)saveClassListJson- Bulk update class list (JSON)getSchoolyearDataOfClass- Get class metadata (e.g., year)saveSchoolyearDataOfClass- Update class metadatagetSkoreClassTeacherCourseRelation- Teacher-course links
Messages
sendMsg- Send a message (optionalattachments,coaccount,copyToLVS)saveSignature- Save message signature
Absences
getAbsents- Get user absencesgetAbsentsWithAlias- Get absences with aliasgetAbsentsByDate- Get absences by dategetAbsentsWithAliasByDate- Get absences with alias by dategetAbsentsWithInternalNumberByDate- Get absences by internal number and dategetAbsentsWithUsernameByDate- Get absences by username and dategetAbsentsByDateAndGroup- Get absences by date and group
Photos
getAccountPhoto- Get user photosetAccountPhoto- Set user photo
Courses
addCourse- Add a course (optionalvisibility)addCourseStudents- Add students to courseaddCourseTeacher- Add teacher to coursegetCourses- Get all courses
Helpdesk
addHelpdeskTicket- Add a helpdesk ticketgetHelpdeskMiniDbItems- Get helpdesk items
Password Management
savePassword- Set/update password
Account Management
getAllAccounts- List all accountsgetAllAccountsExtended- Extended list of accountsgetUserOfficialClass- Get userβs official class (optionaldate)
Data Sync/System
startSkoreSync- Start synchronizationcheckStatus- Check service statusclearGroup- Remove all users from a group (optionalofficialDate)unregisterStudent- Unregister student (optionalofficialDate)
Co-Accounts
removeCoAccount- Delete co-account
Student Career
getStudentCareer- Get student career history
Parameters
getReferenceField- Retrieve reference field
Error Handling
Note:* The API itself handles error code translations. By default, the API returns error codes, and we fetch them to translate them into clear error messages using the SmartschoolError class.
returnCsvErrorCodes- List error codes in CSVreturnJsonErrorCodes- List error codes in JSON
Deprecated
deactivateTwoFactorAuthentication- No longer supported by Smartschool
Type Definitions
The client includes comprehensive TypeScript definitions for all methods. Example:
interface SaveUser { username: string; name: string; surname: string; basisrol: string; email?: string; // ... other optional fields } interface SendMessage { userIdentifier: string; title: string; body: string; senderIdentifier?: string; attachments?: Array<{ filename: string; filedata: string; }>; coaccount?: number; copyToLVS?: boolean; }
Error Handling
The client provides proper error handling:
try { await client.saveUser({...}); } catch (error) { if (error instanceof SmartschoolError) { console.error("API Error:", error.code, error.message); } else { console.error("Network or other error:", error); } }
CLI Configuration
Create a config.json file:
{ "apiEndpoint": "https://your-school.smartschool.be/Webservices/V3", "accesscode": "your-access-code" }
Contributing
Contributions are welcome! Please submit pull requests with any improvements.
License
MIT License - see LICENSE file for details
Add Package
deno add jsr:@abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";
Import directly with a jsr specifier
import * as smartschool_kit from "jsr:@abrianto/smartschool-kit";
Add Package
pnpm i jsr:@abrianto/smartschool-kit
pnpm dlx jsr add @abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";
Add Package
yarn add jsr:@abrianto/smartschool-kit
yarn dlx jsr add @abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";
Add Package
vlt install jsr:@abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";
Add Package
npx jsr add @abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";
Add Package
bunx jsr add @abrianto/smartschool-kit
Import symbol
import * as smartschool_kit from "@abrianto/smartschool-kit";