Dashboard
| Time | Matched Name | Confidence | Result |
|---|---|---|---|
| Loading... | |||
💾 ลงทะเบียนใบหน้า
🔎 Face Compare Test
เปรียบเทียบใบหน้า 2 รูปว่าเป็นคนเดียวกันหรือไม่ — ทดสอบประสิทธิภาพของ Face Matching Engine
| # | ผล | ความเชื่อมั่น | ประมวลผล | เวลา |
|---|---|---|---|---|
| ยังไม่มีการทดสอบ | ||||
| Time | Name | Matches | Result |
|---|---|---|---|
| No scans yet | |||
Registered Faces
| Photo | Name | Employee ID | Department | Registered | Actions |
|---|---|---|---|---|---|
| Loading... | |||||
👥 Sync Check — Attendance vs Face Registration
| # | Citizen ID | ชื่อ (TH) | Name (EN) | Department | Action |
|---|---|---|---|---|---|
| Click Refresh to load | |||||
📍 Scan Logs — บันทึกการลงเวลา
ประวัติการแสกนหน้า พร้อม IP Address และ Location
| เวลา | ชื่อ | รหัสพนักงาน | ประเภท | ความเชื่อมั่น | สถานะ | Attendance | IP Address | Location |
|---|---|---|---|---|---|---|---|---|
| Loading... | ||||||||
User Management
| Username | Display Name | Role | Status | Created | Actions |
|---|---|---|---|---|---|
| Loading... | |||||
API Key Management
| Name | Key | Created By | Status | Last Used | Actions |
|---|---|---|---|---|---|
| Loading... | |||||
Include the API key in your request header:
X-API-Key: fm_your_api_key_here
Activity Logs
| Time | Action | Detail | User | IP |
|---|---|---|---|---|
| Loading... | ||||
Settings
API Documentation
REST API reference for integrating Face Matching into your application.
Base URL:
·
Open Swagger UI
This API uses InsightFace ArcFace (buffalo_l) for face recognition. It extracts 512-dimensional face embeddings and compares them using cosine similarity.
POST /api/faces/registerPOST /api/faces/match or scan 1:N via POST /api/faces/scanPUT /api/faces/update/{employee_id}GET /api/faces/statsทุก endpoint ภายใต้ /api/faces/* ต้องยืนยันตัวตน — ใช้ได้ 2 แบบ (อย่างใดอย่างหนึ่ง)
1. API Key ThirdParty
X-API-Key: fm_your_api_key_here
2. JWT Bearer ผู้ใช้เว็บ
Authorization: Bearer <token จาก /api/admin/login>
สร้าง/ปิดใช้ API Key ได้ที่หน้า API Keys (admin เท่านั้น) — ถ้าไม่ส่ง header, key ถูกปิด, หรือ token หมดอายุ จะได้ 401 Unauthorized
ยกเว้น /api/health, /api/admin/login, /api/admin/captcha ที่เรียกได้โดยไม่ต้องยืนยันตัวตน
/api/faces/register
Register a new face into the database. employee_id must be unique. Returns 409 if already registered.
Request multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image | file | Required | Face photo (JPG, PNG, BMP, WebP) |
employee_id | string | Required | Unique employee identifier |
name | string | Optional | Full name (display) |
citizen_id | string | Optional | National ID / citizen ID |
department | string | Optional | Department name |
employee_type | string | Optional | ประเภทพนักงาน: D = รายวัน, M = ประจำ (บันทึกที่ master_employee ใน Attendance) |
th_prefix | string | Optional | Thai prefix (นาย / นาง / นางสาว) |
th_firstname | string | Optional | Thai first name |
th_lastname | string | Optional | Thai last name |
en_prefix | string | Optional | English prefix |
en_firstname | string | Optional | English first name |
en_lastname | string | Optional | English last name |
birthday | string | Optional | Date of birth (ISO 8601) |
sex | string | Optional | Sex code (1 = male, 2 = female) |
address | string | Optional | Full address |
addr_tambol | string | Optional | Sub-district (ตำบล) |
addr_amphur | string | Optional | District (อำเภอ) |
addr_province | string | Optional | Province (จังหวัด) |
issue | string | Optional | Card issue date (ISO 8601) |
expire | string | Optional | Card expiry date (ISO 8601) |
issuer | string | Optional | Issuing authority |
Response 200 OK
{
"id": 1,
"employee_id": "EMP001",
"name": "John Doe",
"department": "Engineering",
"citizen_id": "1234567890123",
"created_at": "2026-01-01T09:00:00"
}
Example
curl -X POST http://localhost:6100/api/faces/register \
-H "X-API-Key: fm_your_api_key_here" \
-F "image=@photo.jpg" \
-F "employee_id=EMP001" \
-F "name=สมชาย ใจดี" \
-F "citizen_id=1234567890123" \
-F "department=Engineering"
/api/faces/update/{employee_id}
Update an existing face record by employee_id. All fields are optional — only provided fields will be updated.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
employee_id | string | Employee ID of the registered face to update |
Request multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image | file | Optional | New face photo — re-extracts embedding |
name | string | Optional | Updated display name |
department | string | Optional | Updated department |
Example
curl -X PUT http://localhost:6100/api/faces/update/EMP001 \
-H "X-API-Key: fm_your_api_key_here" \
-F "name=สมชาย ใจดีมาก" \
-F "image=@new_photo.jpg"
/api/faces/match
1:1 verification — compare a photo against one specific employee. Returns whether the face matches and the confidence score.
Request multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image | file | Required | Photo of face to verify |
employee_id | string | Required | Employee ID to match against |
threshold | float | Optional | Cosine similarity threshold (default: 0.4) |
Response 200 OK
{
"matched": true,
"employee_id": "EMP001",
"name": "สมชาย ใจดี",
"confidence": 0.8712,
"face_id": 1
}
Example
curl -X POST http://localhost:6100/api/faces/match \
-H "X-API-Key: fm_your_api_key_here" \
-F "image=@photo.jpg" \
-F "employee_id=EMP001"
/api/faces/scan
1:N scan — match a photo against all registered faces. Returns every match above the threshold, sorted by confidence (highest first). เมื่อ match สำเร็จ (ไม่กำกวม) จะบันทึกลงเวลาเข้า AttendanceAPI ให้อัตโนมัติ (ควบคุมเปิด/ปิดที่หน้า Settings) โดยส่ง typeScan="FACE" และ employee_type ตามที่เลือก
Request multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image | file | Required | ภาพหน้าตรง (ใช้ match) |
pose_image | file | Optional | ภาพหันหน้าตามทิศที่สุ่ม — เปิดใช้ pose challenge กันภาพถ่าย (ต้องส่งคู่กับ pose_direction) |
pose_direction | string | Optional | L = หันซ้าย, R = หันขวา — ระบบตรวจทิศ + ยืนยันเป็นคนเดียวกันทั้ง 2 ภาพ ไม่ผ่าน = spoof_detected |
threshold | float | Optional | Cosine similarity threshold (default: 0.4) |
scan_type | string | Optional | ประเภทพนักงาน: D = รายวัน, M = ประจำ — ถ้าไม่ระบุ ใช้ค่าจากข้อมูลลงทะเบียน (master) อัตโนมัติ |
send_attendance | boolean | Optional | ส่งลงเวลาเข้า AttendanceApi หรือไม่ (true/false) — สำหรับ ThirdParty; ถ้าไม่ระบุ ใช้ค่าจากหน้า Settings |
latitude, longitude | float | Optional | พิกัด GPS ของจุดสแกน |
location_name | string | Optional | ชื่อสถานที่ |
Response 200 OK
{
"matches": [
{
"face_id": 1,
"employee_id": "EMP001",
"name": "สมชาย ใจดี",
"department": "Engineering",
"confidence": 0.9123
}
],
"no_face": false
}
When no face is detected: {"matches": [], "no_face": true}
Example
curl -X POST http://localhost:6100/api/faces/scan \
-H "X-API-Key: fm_your_api_key_here" \
-F "image=@photo.jpg"
/api/faces/
List all registered faces, ordered by most recently added.
Response 200 OK — array
[
{
"id": 1,
"employee_id": "EMP001",
"name": "สมชาย ใจดี",
"department": "Engineering",
"citizen_id": "1234567890123",
"created_at": "2026-01-01T09:00:00"
}
]
/api/faces/{face_id}
Delete a registered face by its database ID. Returns 404 if the face does not exist.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
face_id | integer | Face database ID (from register or list response) |
Response 200 OK
{ "detail": "Deleted", "id": 1 }
Example
curl -X DELETE http://localhost:6100/api/faces/1 \
-H "X-API-Key: fm_your_api_key_here"
/api/faces/stats
Get summary statistics and the last 20 match logs.
Response 200 OK
{
"total_faces": 42,
"total_matches": 1200,
"successful_matches": 1150,
"failed_matches": 50,
"no_face_detected": 10,
"match_rate": 95.83,
"avg_confidence": 0.8521,
"faces_by_department": {
"Engineering": 20,
"HR": 12
},
"recent_logs": [
{
"id": 1,
"matched_name": "สมชาย ใจดี",
"confidence": 0.8712,
"result": "matched",
"created_at": "2026-01-01T09:01:00"
}
]
}
/api/health
Health check. Returns server status, uptime, memory, and CPU usage. No authentication required.
Response 200 OK
{
"status": "healthy",
"uptime_seconds": 3600.5,
"memory_mb": 512.3,
"cpu_percent": 12.4
}
/api/faces/scan-config
ค่าตั้งค่าฝั่ง client สำหรับหน้า Live Scan (อ่านได้ทุก role) เช่น เปิด/ปิด Auto Scan — ตั้งค่าที่หน้า Settings
Response 200 OK
{ "auto_scan": true }
/api/faces/scan-logs
ประวัติการสแกนล่าสุด (ทุกผลลัพธ์) เรียงจากใหม่ไปเก่า
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
limit | int | Optional | จำนวนสูงสุด (default 200) |
result_filter | string | Optional | กรองตามผล: matched / confirmed / unmatched / no_face |
Response 200 OK
[
{
"id": 12, "employee_id": "11969", "name": "สุรสิทธิ์ บอช",
"confidence": 0.87, "result": "matched", "scan_type": "D",
"attendance_sent": true, "created_at": "2026-07-02T09:01:00"
}
]
/api/faces/timescan
รายการลงเวลาของพนักงาน 1 คน ตามช่วงวันที่ (นับรวมวันเริ่ม-สิ้นสุด) เฉพาะผลที่เป็นการลงเวลาจริง (matched / confirmed)
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
employee_id | string | Required | รหัสพนักงาน |
start_date | string | Required | วันเริ่ม รูปแบบ YYYY-MM-DD |
end_date | string | Required | วันสิ้นสุด รูปแบบ YYYY-MM-DD |
Example
curl "$BASE/api/faces/timescan?employee_id=11969&start_date=2026-07-01&end_date=2026-07-31"
Response 200 OK
{
"employee_id": "11969",
"start_date": "2026-07-01", "end_date": "2026-07-31",
"count": 2,
"records": [ { "id": 12, "name": "...", "scan_type": "D", "created_at": "..." } ]
}
/api/faces/timescan-list
รายการลงเวลาของ ทุกคน ตามช่วงวันที่ (ระบุ employee_id เพื่อกรองเฉพาะคนได้)
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
start_date | string | Required | วันเริ่ม YYYY-MM-DD |
end_date | string | Required | วันสิ้นสุด YYYY-MM-DD |
employee_id | string | Optional | กรองเฉพาะพนักงานคนนี้ |
Response 200 OK
{
"start_date": "2026-07-01", "end_date": "2026-07-31",
"count": 128,
"records": [ /* ScanLog objects */ ]
}
| Status | Meaning | Common Cause |
|---|---|---|
400 | Bad Request | No face detected in the uploaded image |
401 | Unauthorized | ไม่ได้ส่ง X-API-Key / Authorization, key ถูกปิด, หรือ token หมดอายุ |
403 | Forbidden | สิทธิ์ไม่พอ (เช่น endpoint ที่ต้องเป็น admin) หรือบัญชีถูกปิดใช้งาน |
404 | Not Found | Employee ID or Face ID does not exist |
409 | Conflict | Employee ID already registered |
422 | Validation Error | Missing required fields or wrong data type |
500 | Server Error | Internal error — check server logs |