ZKTeco Attendance Sync

Project Documentation

Platform: Windows 10/11
Application type: PyQt6 desktop application
Supported terminal family: ZKTeco devices compatible with PyZK
Device port: TCP 4370
Storage options: MySQL, REST API, or Hybrid

1. Project overview

ZKTeco Attendance Sync connects one or more attendance terminals directly to a Windows computer over the local network. It downloads punch records, prevents duplicate storage, displays live attendance, manages terminal users, and optionally delivers attendance to a remote API.

Each enabled terminal runs in an independent background thread. A slow, disconnected, or unavailable terminal therefore does not intentionally block the other configured terminals.

The application supports three operating modes:

  1. API mode — sends newly detected punches to an HTTP API in real time.
  2. Local Database mode — stores attendance in a local or network-accessible MySQL database.
  3. Hybrid mode — saves each new punch locally first and then sends it through the API queue.

2. Main features

3. Application startup and licensing

The application checks its offline license before opening the main window. An unlicensed or expired installation displays the activation window and its Machine ID.

First activation

  1. Open the application on the customer computer.
  2. Select Copy Machine ID.
  3. Send the Machine ID to the license issuer.
  4. The issuer generates a signed JSON license.
  5. Select Import License and choose that JSON file.
  6. The application verifies the signature, Machine ID, expiry date, and device limit.

License upgrade

An active license can be replaced before it expires:

  1. Generate a replacement license for the same Machine ID.
  2. Open Preferences.
  3. Under License, select Upgrade License.
  4. Import the replacement JSON file.

If the installed license has expired, import the replacement from the startup activation window.

Device limits

The license controls the maximum number of device configurations. The application rejects saving or starting synchronization when the configured count exceeds the licensed limit.

4. Main window and navigation

The application opens maximized and provides the following pages:

Closing the main window normally minimizes the application to the system tray. Use the tray menu's Exit action for a complete and safe worker shutdown.

5. Connection modes

5.1 API mode

API mode does not require the local MySQL attendance database. Every device worker detects new punches and places them in the shared API delivery queue.

Available functionality includes:

Local dashboard data, stored attendance, local export, and safe terminal cleanup are unavailable because API mode has no local attendance archive.

5.2 Local Database mode

Local Database mode stores device, employee, raw punch, daily attendance, and synchronization information in MySQL.

Available functionality includes:

5.3 Hybrid mode

Hybrid mode combines the existing local and API paths:

Terminal punch
      |
      v
Local duplicate-safe insert
      |
      +----> Live Attendance and local reports
      |
      v
Real-time API queue
      |
      v
Remote attendance API

Only punches accepted as new by the local database are placed in the live API queue. This prevents repeated terminal downloads from generating repeated live API submissions during the same local archive workflow.

If live API delivery fails after its retry attempts, the local record remains available. In Hybrid mode, the date-range synchronization action can be used to deliver locally stored records again.

6. Multiple-device management

Open Device Configuration to manage terminals.

Create a device

  1. Select Create New Device.
  2. Enter a unique device name.
  3. Enter its IP address and port.
  4. Enter the communication password.
  5. Configure timeout and polling interval.
  6. Select whether the device is enabled.
  7. Select Test Selected.
  8. Select Save All.

In Local or Hybrid mode, Save All also inserts or updates the terminals in the MySQL devices table.

Device rules

Device actions

7. Dashboard

The Dashboard provides operational and attendance totals:

Use the device selector to display all devices together or filter the dashboard to one terminal.

8. Local database configuration

The Database Configuration page accepts:

Use Test Database Connection to validate credentials. Use Initialize Database for the first installation. The configured MySQL account must initially have permission to create the selected database. After initialization, normal SELECT, INSERT, and UPDATE permissions are required.

Main local tables

Table Purpose
devices Terminal configuration and connection state
employees Employee profiles separated by device
attendance_logs Complete raw punch archive
daily_attendance Daily attendance summary
sync_status Synchronization totals, timestamps, and errors
application_logs Optional database-side application log structure

Raw punch duplicate protection uses:

device_id + employee_code + punch_time

This allows the same employee number or timestamp to exist independently on different terminals.

9. Live Attendance

The Live Attendance page displays locally stored attendance records with:

Use the device selector to show records from all devices or one selected terminal. The page refreshes periodically and also refreshes when a new local punch arrives.

Available output actions:

10. Employee management

The Employees page supports both database viewing and direct machine-user operations.

Employee information includes:

Machine-user workflow

  1. Start device synchronization.
  2. Select a specific device on the Employees page.
  3. Select View Users from Machine.
  4. Add, edit, or delete users as required.

Machine operations require a specific device selection to prevent changes on the wrong terminal.

Deleting a terminal user does not remove historical attendance. In Local and Hybrid modes, the local employee profile is marked inactive.

11. API configuration and delivery

The API Connection page supports:

Live records are sent as JSON. Authentication uses:

Authorization: Bearer <api-key>

The client also sends an Idempotency-Key header. Failed live requests are retried up to three times by the API worker.

Example request:

{
  "mode": "live",
  "count": 1,
  "records": [
    {
      "device_id": 1,
      "employee_code": "1001",
      "punch_time": "2026-07-22T08:30:00",
      "status": 0,
      "verify_mode": 1,
      "work_code": ""
    }
  ]
}

11.1 Endpoint and HTTP headers

The desktop client sends attendance using POST to the configured endpoint. The base URL can be either an API directory or the complete PHP endpoint URL.

Example endpoints:

https://attendance.example.com/api/iclock
https://attendance.example.com/api/ + /iclock

Request headers:

Accept: application/json
Content-Type: application/json
User-Agent: ZKTecoAttendanceSync/1.0
Authorization: Bearer YOUR_API_KEY
Idempotency-Key: DEVICE:EMPLOYEE:PUNCH_TIME

Authorization is omitted when no API key is configured. Idempotency-Key is generated automatically and is limited to 240 characters by the desktop client.

12. Logs and troubleshooting

Application messages are available on the Application Logs page and in the rotating log file:

Available actions include:

Common connection checks:

13. Preferences and Windows integration

Preferences include:

14. Security

15. Support

This is an independently developed companion utility and is not an official ZKTeco product. ZKTeco is the name of the compatible terminal family; all related trademarks belong to their respective owners.

For the cloud POS, inventory, reporting, and retail management platform, visit the RetailEase main site.

Copyright © 2026 Ali Akbar. All rights reserved.

Contact: aliakbarcse@yahoo.com

WhatsApp: +88 01837-023812