js-zklib
v1.0.1
Published
JavaScript module for ZKTeco biometric devices
Maintainers
Readme
js-zklib
A JavaScript library for interacting with ZK Time & Attendance devices.
Installation
npm i js-zklibUsage
Available Functions
createSocket(): Establish connection with the devicegetInfo(): Get general device informationgetUsers(): Retrieve users from the devicesetUser(uid, userid, name, password, role = 0, cardno = 0): Create a new usergetAttendances(callback): Get all attendance logsgetRealTimeLogs(callback): Get real-time logsgetTime(): Get current time from the devicegetSerialNumber(): Get device serial numbergetFirmware(): Get firmware versiongetPIN(): Get device PINgetFaceOn(): Check if face recognition is enabledgetSSR(): Get Self-Service-Recorder statusgetDeviceVersion(): Get device versiongetDeviceName(): Get device namegetPlatform(): Get platform versiongetOS(): Get OS versiongetWorkCode(): Get work codegetAttendanceSize(): Get attendance log sizeclearAttendanceLog(): Clear attendance logsdisconnect(): Disconnect from the device
Custom Commands
You can execute custom commands using the executeCmd function:
async executeCmd(command, data='') {
return await this.functionWrapper(
() => this.zklibTcp.executeCmd(command, data),
() => this.zklibUdp.executeCmd(command, data)
)
}
// Example: Unlock the door
zkInstance.executeCmd(CMD.CMD_UNLOCK, '')For more commands, refer to the ZK protocol documentation.
Credits
This library is based on:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
