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.
- ๐ 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
# From JSR
jsr add @abrianto/smartschool-client
# Direct import
import { SmartschoolClient } from "jsr:@abrianto/smartschool-client";
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",
firstName: "John",
lastName: "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"
});
# Get help
deno run --allow-net ./bin/cli.ts --help
# Create a user
deno run --allow-net ./bin/cli.ts \
--method=saveUser \
--config=./config.json \
--username=john.doe \
--firstName=John \
--lastName=Doe
# 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
See coverage
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
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
sendMsg
- Send a message (optionalattachments
,coaccount
,copyToLVS
)saveSignature
- Save message signature
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
getAccountPhoto
- Get user photosetAccountPhoto
- Set user photo
addCourse
- Add a course (optionalvisibility
)addCourseStudents
- Add students to courseaddCourseTeacher
- Add teacher to coursegetCourses
- Get all courses
addHelpdeskTicket
- Add a helpdesk ticketgetHelpdeskMiniDbItems
- Get helpdesk items
savePassword
- Set/update password
getAllAccounts
- List all accountsgetAllAccountsExtended
- Extended list of accountsgetUserOfficialClass
- Get userโs official class (optionaldate
)
startSkoreSync
- Start synchronizationcheckStatus
- Check service statusclearGroup
- Remove all users from a group (optionalofficialDate
)unregisterStudent
- Unregister student (optionalofficialDate
)
removeCoAccount
- Delete co-account
getStudentCareer
- Get student career history
getReferenceField
- Retrieve reference field
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
deactivateTwoFactorAuthentication
- No longer supported by Smartschool
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;
}
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);
}
}
Create a config.json
file:
{
"apiEndpoint": "https://your-school.smartschool.be/Webservices/V3",
"accesscode": "your-access-code"
}
Contributions are welcome! Please submit pull requests with any improvements.
MIT License - see LICENSE file for details