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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: 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 POST

Description: Delete the face data of a specified user.

Request Example

{
    "cmd": "deleteuserface",
    "password": "device password",
    "enrollid": "1"
}

13. deleteuserfp - Delete User Fingerprint

HTTP POST

Description: Delete all fingerprint data of a specified user.

Request Example

{
    "cmd": "deleteuserfp",
    "password": "device password",
    "enrollid": "1"
}

14. deleteuserpalm - Delete User Palmprint

HTTP POST

Description: Delete all palmprint data of a specified user.

Request Example

{
    "cmd": "deleteuserpalm",
    "password": "device password",
    "enrollid": "1"
}

15. deleteusers - Batch Delete Users

HTTP POST

Description: Delete multiple users in batch.

Request Example

{
    "cmd": "deleteusers",
    "password": "device password",
    "list": ["1", "2", "3"]
}

16. cleanuser - Clear All Users

HTTP POST

Description: Delete all user data.

Request Example

{
    "cmd": "cleanuser",
    "password": "device password"
}

17. getlog - Get Attendance Records

HTTP POST

Description: 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 POST

Description: Get real-time records (automatically deleted after retrieval).

Request Example

{
    "cmd": "getrtlog",
    "password": "device password"
}

19. setlogs - Add Records

HTTP POST

Description: 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 POST

Description: Delete all attendance records.

21. initsys - System Initialization

HTTP POST

Description: Clear all users and records, restore some settings.

22. gettime - Get Device Time

HTTP POST

Description: 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 POST

Description: Set the device time.

Request Example

{
    "cmd": "settime",
    "password": "device password",
    "cloudtime": "2025-05-17 12:00:00"
}

24. cleanadmin - Clear All Administrators

HTTP POST

Description: Clear administrator privileges for all users.

25. cleaninactiveuser - Clear Inactive Users

HTTP POST

Description: Delete inactive users.

26. cleanlogphoto - Clear Log Photos

HTTP POST

Description: Delete all photos saved in logs.

27. initmenu - Initialize Menu Settings

HTTP POST

Description: Restore menu-related settings to default values.

28. cleandatebase - Clear Database

HTTP POST

Description: Clear the database and trigger a reboot.

29. setdevinfo - Set Device Parameters

HTTP POST

Description: 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 POST

Description: Get all configuration parameters of the device.

31. getdevcap - Get Device Capacity

HTTP POST

Description: Get the capacity and usage of each device module (Users, Faces, Logs).

32. opendoor - Open Door

HTTP POST

Description: 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 POST

Description: Control the door lock status (1=Normally open, 2=Normally closed, 3=Restore normal).

34. enableuser - Enable User

HTTP POST

Description: Enable or disable a user (enflag: 1=Enable, 0=Disable).

35. setdevlock - Set Access Parameters

HTTP POST

Description: Set device access control related parameters like open delay, sensors, timezones.

36. getdevlock - Get Access Parameters

HTTP POST

Description: Get the device access control configuration parameters.

37. getuserlock - Get User Access Parameters

HTTP POST

Description: Get the access parameters of a specified user.

38. setuserlock - Set User Access Parameters

HTTP POST

Description: Batch set access parameters for users (verifymode, weekzone, etc.).

39. deleteuserlock - Delete User Access Parameters

HTTP POST

Description: Delete the access parameters of a specified user.

40. cleanuserlock - Clear All User Access Parameters

HTTP POST

Description: Clear access parameters for all users.

41. getdoorstatus - Get Door Status

HTTP POST

Description: Get the current door status (0=Closed, 1=Open).

42. setscreensaver - Set Screensaver

HTTP POST

Description: Set, delete single, or clear all screensaver images of the device.

43. getshift - Get Shift Schedule

HTTP POST

Description: Get the shift schedule configuration of the device.

44. setshift - Set Shift Schedule

HTTP POST

Description: Set the shift schedule configuration of the device.

45. getbelltime - Get Bell Time

HTTP POST

Description: Get the bell time configuration of the device.

46. setbelltime - Set Bell Time

HTTP POST

Description: Set the bell time configuration of the device.

47. getreport - Get Attendance Report

HTTP POST

Description: 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 POST

Description: Reboot the device. Note: The device reboots immediately, no response will be sent.

49. disabledevice - Disable Device

HTTP POST

Description: Temporarily disable device functions such as face recognition.

50. enabledevice - Enable Device

HTTP POST

Description: Restore normal functions of the device.

51. adduser - Add User (Active Enrollment)

HTTP POST

Description: 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 POST

Description: Query the progress and result of active enrollment triggered by adduser.

53. setquestionnaire - Set Questionnaire

HTTP POST

Description: Configure the questionnaire function (e.g., temperature check questions).

54. getquestionnaire - Get Questionnaire

HTTP POST

Description: Get the questionnaire configuration.

55. cleanquestionnaire - Clear Questionnaire

HTTP POST

Description: Clear the questionnaire configuration.

56. setcompanyname - Set Company Name

HTTP POST

Description: Set the company name displayed on the device.

57. getcompanyname - Get Company Name

HTTP POST

Description: Get the company name displayed on the device.

58. setholiday - Set Holidays

HTTP POST

Description: Set holiday configuration with specific date ranges.

59. getholiday - Get Holidays

HTTP POST

Description: Get the holiday configuration.

60. upgrade - Firmware Upgrade

HTTP POST

Description: 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 POST

Description: Upload or play custom voice files (WAV format).

62. keypad - Keypad Input

HTTP POST

Description: Control the display of the on-screen keypad.

63. verify - Remote Verification

HTTP POST

Description: 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 POST

Description: Elevator control: Grant access to all floors.

65. closeallfloors - Close All Floors

HTTP POST

Description: Elevator control: Revoke access to all floors.

66. openselectfloors - Open Selected Floors

HTTP POST

Description: Elevator control: Grant access to specified floors (e.g., "3,5,7").

67. closeselectfloors - Close Selected Floors

HTTP POST

Description: Elevator control: Revoke access to specified floors.

68. getdir - Get Directory List

HTTP POST

Description: Get the list of files in a directory on the device.

69. getfile - Get File

HTTP POST

Description: Get the content of a file on the device (Base64 encoded).

70. writefile - Write File

HTTP POST

Description: Write a file to the device storage.

71. generatereport - Generate Report

HTTP POST

Description: Trigger the generation of an attendance report file on the device.

72. checkreportprogress - Check Report Generation Progress

HTTP POST

Description: 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