Webserver+JSON Communication Protocol
General Information
| Protocol Type | HTTP |
|---|---|
| Port | 80 |
| Data Format | JSON |
| Character Encoding | UTF-8 |
| Authentication | All requests must include the password field. |
This document describes the communication protocol between a web server and the device using JSON format over HTTP.
API Commands
1. login - Login Authentication
HTTP POSTDescription: Verify administrator username and password.
Request Example
{
"cmd": "login",
"username": "admin",
"password": "device password"
}
Response Example (Success)
{
"ret": "login",
"sn": "device serial number",
"result": true
}
2. reg - Device Registration
HTTP POSTDescription: Device registers with the server, reporting device information and status.
Request Example
{
"cmd": "reg",
"password": "device password"
}
Response Example
{
"ret": "reg",
"sn": "device serial number",
"devinfo": {
"modelname": "AiFace",
"manufacturer": "manufacturer name",
"fpalgo": "thbio3.0",
"firmware": "firmware version",
"time": "2025-05-17 10:30:00",
"curip": "192.168.1.100",
"timezone": "GMT+8",
"usersize": 3000,
"facesize": 3000,
"logsize": 100000,
"useduser": 100,
"usedface": 80,
"usedlog": 5000
// ... other status fields
}
}
3. getlang - Get Current Language
HTTP POSTDescription: Get the current language used by the device.
Request Example
{
"cmd": "getlang",
"password": "device password"
}
Response Example
{
"ret": "getlang",
"sn": "device serial number",
"result": true,
"lang": "en-US"
}
4. getlangoption - Get Supported Language List
HTTP POSTDescription: Get all language options supported by the device.
Request Example
{
"cmd": "getlangoption",
"password": "device password"
}
Response Example
{
"ret": "getlangoption",
"sn": "device serial number",
"result": true,
"langs": [
{"lvalue": 0, "ltitle": "English"},
{"lvalue": 1, "ltitle": "Simplified Chinese"}
]
}
5. getuserlist - Get User List
HTTP POSTDescription: Get basic information of all users by pagination. stn: true means start reading from beginning.
Request Example
{
"cmd": "getuserlist",
"password": "device password",
"stn": true
}
Response Example
{
"ret": "getuserlist",
"sn": "device serial number",
"result": true,
"count": 100,
"record": [
{
"id": "1",
"name": "John Doe",
"admin": 0,
"face": 1,
"card": 12345678
}
]
}
6. getuserids - Get All User IDs
HTTP POSTDescription: Get the list of all user IDs (without detailed information).
Request Example
{
"cmd": "getuserids",
"password": "device password"
}
Response Example
{
"ret": "getuserids",
"sn": "device serial number",
"result": true,
"count": 100,
"record": ["1", "2", "3", "100"]
}
7. getunuserdid - Get Available Empty User ID
HTTP POSTDescription: Get an available empty user ID for adding a new user.
Request Example
{
"cmd": "getunuserdid",
"password": "device password"
}
Response Example
{
"ret": "getunuserdid",
"sn": "device serial number",
"result": true,
"enrollid": "101"
}
8. checkuserid - Check User ID Existence
HTTP POSTDescription: Check whether the specified user ID already exists.
Request Example
{
"cmd": "checkuserid",
"password": "device password",
"enrollid": "1"
}
Response Example
{
"ret": "checkuserid",
"sn": "device serial number",
"result": true,
"exists": true
}
9. getuserinfo - Get User Details
HTTP POSTDescription: Get complete information of a specified user. Use backupnum to specify data type (0: FP, 50: Face Photo, 51: Face Feature).
Request Example
{
"cmd": "getuserinfo",
"password": "device password",
"enrollid": "1"
}
Response Example
{
"ret": "getuserinfo",
"sn": "device serial number",
"result": true,
"enrollid": "1",
"name": "John Doe",
"card": 12345678,
"faceflag": 1
}
10. setuserinfo - Set User Information
HTTP POSTDescription: Add or update user information (fingerprint, card, password, face, etc.).
Request Example (Set Basic Info)
{
"cmd": "setuserinfo",
"password": "device password",
"enrollid": "1",
"name": "John Doe",
"card": 12345678
}
Response Example
{
"ret": "setuserinfo",
"sn": "device serial number",
"result": true,
"enrollid": "1"
}
11. deleteuser - Delete User Information
HTTP POSTDescription: Delete a user or specific templates. backupnum: 13 deletes the entire user.
Request Example
{
"cmd": "deleteuser",
"password": "device password",
"enrollid": "1",
"backupnum": 13
}
Response Example
{
"ret": "deleteuser",
"sn": "device serial number",
"result": true,
"enrollid": "1"
}
12. deleteuserface - Delete User Face
HTTP POSTDescription: Delete the face data of a specified user.
Request Example
{
"cmd": "deleteuserface",
"password": "device password",
"enrollid": "1"
}
13. deleteuserfp - Delete User Fingerprint
HTTP POSTDescription: Delete all fingerprint data of a specified user.
Request Example
{
"cmd": "deleteuserfp",
"password": "device password",
"enrollid": "1"
}
14. deleteuserpalm - Delete User Palmprint
HTTP POSTDescription: Delete all palmprint data of a specified user.
Request Example
{
"cmd": "deleteuserpalm",
"password": "device password",
"enrollid": "1"
}
15. deleteusers - Batch Delete Users
HTTP POSTDescription: Delete multiple users in batch.
Request Example
{
"cmd": "deleteusers",
"password": "device password",
"list": ["1", "2", "3"]
}
16. cleanuser - Clear All Users
HTTP POSTDescription: Delete all user data.
Request Example
{
"cmd": "cleanuser",
"password": "device password"
}
17. getlog - Get Attendance Records
HTTP POSTDescription: Get attendance/access records by pagination.
Request Example
{
"cmd": "getlog",
"password": "device password",
"index": 0,
"from": "2025-05-01",
"to": "2025-05-31"
}
Response Example
{
"ret": "getlog",
"sn": "device serial number",
"result": true,
"record": [
{
"enrollid": "1",
"name": "John Doe",
"time": "2025-05-17 08:30:00",
"event": 1
}
]
}
18. getrtlog - Get Real-time Records
HTTP POSTDescription: Get real-time records (automatically deleted after retrieval).
Request Example
{
"cmd": "getrtlog",
"password": "device password"
}
19. setlogs - Add Records
HTTP POSTDescription: Manually add attendance records.
Request Example
{
"cmd": "setlogs",
"password": "device password",
"records": [
{ "id": "1", "event": 1, "time": "2025-05-17 08:30:00" }
]
}
20. cleanlog - Clear All Records
HTTP POSTDescription: Delete all attendance records.
21. initsys - System Initialization
HTTP POSTDescription: Clear all users and records, restore some settings.
22. gettime - Get Device Time
HTTP POSTDescription: Get the current time of the device.
Response Example
{
"ret": "gettime",
"sn": "device serial number",
"time": "2025-05-17 10:30:00"
}
23. settime - Set Device Time
HTTP POSTDescription: Set the device time.
Request Example
{
"cmd": "settime",
"password": "device password",
"cloudtime": "2025-05-17 12:00:00"
}
24. cleanadmin - Clear All Administrators
HTTP POSTDescription: Clear administrator privileges for all users.
25. cleaninactiveuser - Clear Inactive Users
HTTP POSTDescription: Delete inactive users.
26. cleanlogphoto - Clear Log Photos
HTTP POSTDescription: Delete all photos saved in logs.
27. initmenu - Initialize Menu Settings
HTTP POSTDescription: Restore menu-related settings to default values.
28. cleandatebase - Clear Database
HTTP POSTDescription: Clear the database and trigger a reboot.
29. setdevinfo - Set Device Parameters
HTTP POSTDescription: Set various configuration parameters (Volume, Language, IP, etc.).
Request Example
{
"cmd": "setdevinfo",
"password": "device password",
"VOLUME": 6,
"LANGUAGE": 0,
"NETIPADDRESS": "192.168.1.100"
}
30. getdevinfo - Get Device Parameters
HTTP POSTDescription: Get all configuration parameters of the device.
31. getdevcap - Get Device Capacity
HTTP POSTDescription: Get the capacity and usage of each device module (Users, Faces, Logs).
32. opendoor - Open Door
HTTP POSTDescription: Control the access control to open the door.
Request Example
{
"cmd": "opendoor",
"password": "device password",
"enrollid": "1",
"msg": "Door opened"
}
33. lockctrl - Lock Control
HTTP POSTDescription: Control the door lock status (1=Normally open, 2=Normally closed, 3=Restore normal).
34. enableuser - Enable User
HTTP POSTDescription: Enable or disable a user (enflag: 1=Enable, 0=Disable).
35. setdevlock - Set Access Parameters
HTTP POSTDescription: Set device access control related parameters like open delay, sensors, timezones.
36. getdevlock - Get Access Parameters
HTTP POSTDescription: Get the device access control configuration parameters.
37. getuserlock - Get User Access Parameters
HTTP POSTDescription: Get the access parameters of a specified user.
38. setuserlock - Set User Access Parameters
HTTP POSTDescription: Batch set access parameters for users (verifymode, weekzone, etc.).
39. deleteuserlock - Delete User Access Parameters
HTTP POSTDescription: Delete the access parameters of a specified user.
40. cleanuserlock - Clear All User Access Parameters
HTTP POSTDescription: Clear access parameters for all users.
41. getdoorstatus - Get Door Status
HTTP POSTDescription: Get the current door status (0=Closed, 1=Open).
42. setscreensaver - Set Screensaver
HTTP POSTDescription: Set, delete single, or clear all screensaver images of the device.
43. getshift - Get Shift Schedule
HTTP POSTDescription: Get the shift schedule configuration of the device.
44. setshift - Set Shift Schedule
HTTP POSTDescription: Set the shift schedule configuration of the device.
45. getbelltime - Get Bell Time
HTTP POSTDescription: Get the bell time configuration of the device.
46. setbelltime - Set Bell Time
HTTP POSTDescription: Set the bell time configuration of the device.
47. getreport - Get Attendance Report
HTTP POSTDescription: Get the attendance report data for a user within a date range.
Request Example
{
"cmd": "getreport",
"password": "device password",
"enrollid": "1",
"from": "2025-05-01",
"to": "2025-05-31"
}
48. reboot - Reboot Device
HTTP POSTDescription: Reboot the device. Note: The device reboots immediately, no response will be sent.
49. disabledevice - Disable Device
HTTP POSTDescription: Temporarily disable device functions such as face recognition.
50. enabledevice - Enable Device
HTTP POSTDescription: Restore normal functions of the device.
51. adduser - Add User (Active Enrollment)
HTTP POSTDescription: Trigger the device's active enrollment mode for fingerprint or face.
Request Example
{
"cmd": "adduser",
"password": "device password",
"enrollid": "1",
"backupnum": 50
}
52. checkregstatus - Check Enrollment Status
HTTP POSTDescription: Query the progress and result of active enrollment triggered by adduser.
53. setquestionnaire - Set Questionnaire
HTTP POSTDescription: Configure the questionnaire function (e.g., temperature check questions).
54. getquestionnaire - Get Questionnaire
HTTP POSTDescription: Get the questionnaire configuration.
55. cleanquestionnaire - Clear Questionnaire
HTTP POSTDescription: Clear the questionnaire configuration.
56. setcompanyname - Set Company Name
HTTP POSTDescription: Set the company name displayed on the device.
57. getcompanyname - Get Company Name
HTTP POSTDescription: Get the company name displayed on the device.
58. setholiday - Set Holidays
HTTP POSTDescription: Set holiday configuration with specific date ranges.
59. getholiday - Get Holidays
HTTP POSTDescription: Get the holiday configuration.
60. upgrade - Firmware Upgrade
HTTP POSTDescription: Upload firmware upgrade package in blocks.
Request Example
{
"cmd": "upgrade",
"password": "device password",
"filename": "firmware.pkg",
"md5": "...",
"index": 0,
"record": "base64 encoded data"
}
61. setvoice - Set Voice
HTTP POSTDescription: Upload or play custom voice files (WAV format).
62. keypad - Keypad Input
HTTP POSTDescription: Control the display of the on-screen keypad.
63. verify - Remote Verification
HTTP POSTDescription: Remotely send face/fingerprint data to the device for comparison.
Request Example
{
"cmd": "verify",
"password": "device password",
"enrollid": "1",
"face": "base64 encoded image"
}
64. openallfloors - Open All Floors
HTTP POSTDescription: Elevator control: Grant access to all floors.
65. closeallfloors - Close All Floors
HTTP POSTDescription: Elevator control: Revoke access to all floors.
66. openselectfloors - Open Selected Floors
HTTP POSTDescription: Elevator control: Grant access to specified floors (e.g., "3,5,7").
67. closeselectfloors - Close Selected Floors
HTTP POSTDescription: Elevator control: Revoke access to specified floors.
68. getdir - Get Directory List
HTTP POSTDescription: Get the list of files in a directory on the device.
69. getfile - Get File
HTTP POSTDescription: Get the content of a file on the device (Base64 encoded).
70. writefile - Write File
HTTP POSTDescription: Write a file to the device storage.
71. generatereport - Generate Report
HTTP POSTDescription: Trigger the generation of an attendance report file on the device.
72. checkreportprogress - Check Report Generation Progress
HTTP POSTDescription: Query the progress of report generation triggered by generatereport.
Technical Appendices
backupnum Value Description
| Value | Description |
|---|---|
| 0-9 | Fingerprint template (0-9 index) |
| 10 | Password |
| 11 | Card |
| 12 | Delete all fingerprints |
| 13 | Delete entire user |
| 40-41 | Palmprint template |
| 50 | Face photo |
| 51 | Face feature data |
Verification Methods (mode)
| Value | Method |
|---|---|
| 0 | Fingerprint |
| 1 | Card |
| 2 | Password |
| 3 | Face |
| 13 | QR Code |
Event Types (event)
| Value | Event |
|---|---|
| 0 | Normal |
| 1 | Clock In |
| 2 | Clock Out |
| 3 | Overtime In |
| 4 | Overtime Out |
| 5-8 | Custom F1-F4 |
Error Codes (reason)
| Value | Description |
|---|---|
| 1 | User not found / Parameter error |
| 2 | Password error / File too large |
| 3 | Device busy / File size is 0 |
| 5 | No face detected in picture |
| 12 | Duplicate face detected |
