Face-scan API โ€” documentation

keystore_id store karo ยท us id se call karo ยท url wapas lo

Basics

Ye API rate API se bilkul alag hai โ€” apna namespace (/api/face-scan/*), apni table (face_scan_keystores) aur apna code folder (src/face-scan/). Rates / passkeys / sections se iska koi lena-dena nahi.

Base URL http://localhost:3000. Sab kuch JSON hai, response ka shape fix hai:

{ "ok": true,  "data": โ€ฆ }        // success
{ "ok": false, "error": "โ€ฆ" }     // failure

Kaise kaam karta hai

  1. Pehle ek keystore_id aur uska url store karo (keys page /face-scan/admin se ya API se).
  2. Koi bhi client us keystore_id se lookup call karta hai.
  3. Response me wahi url milta hai.
POST /api/face-scan/keystores   { "keystore_id": "ks_1001", "url": "https://scan.example.com/s/ks_1001" }
                                   (koi passkey / secret nahi)

GET  /api/face-scan/url/ks_1001
  -> { "ok": true, "data": { "keystore_id": "ks_1001", "url": "https://scan.example.com/s/ks_1001" } }

Ek keystore_id = ek url. Url badalna ho to PATCH karo โ€” client ko wahi id se naya url milne lagega.

Authentication

Koi authentication nahi hai. Face-scan ki kisi bhi call me passkey, secret ya key nahi lagti โ€” na url lene me, na store / edit / delete me. Rate API ki passkeys se iska koi lena-dena nahi.

Sab kuch khula hai. Jiske paas keystore_id hai wo url le sakta hai, aur jise server ka address pata hai wo kisi bhi keystore ko add / badal / delete kar sakta hai. Isliye keystore_id andaaza lagane layak mat rakho (ks_1, ks_2 โ€ฆ).

URL lookup

Teeno tarike ek hi kaam karte hain โ€” jo suit kare:

MethodPathkeystore_id kahan
GET/api/face-scan/url/:keystore_idpath me
GET/api/face-scan/url?keystore_id=โ€ฆquery me
POST/api/face-scan/urlJSON body { "keystore_id": "โ€ฆ" }
# 1. path me
curl http://localhost:3000/api/face-scan/url/ks_1001

# 2. query me
curl "http://localhost:3000/api/face-scan/url?keystore_id=ks_1001"

# 3. body me
curl -X POST http://localhost:3000/api/face-scan/url \
     -H 'content-type: application/json' \
     -d '{"keystore_id":"ks_1001"}'

Response:

{
  "ok": true,
  "data": {
    "keystore_id": "ks_1001",
    "url": "https://scan.example.com/s/ks_1001"
  }
}

Har successful lookup par us keystore ka hits +1 aur last_used_at update hota hai (GET /api/face-scan/keystores/:keystore_id me dikhta hai).

SituationResponse
keystore_id nahi bheja400 `keystore_id` is required
Wo keystore_id store hi nahi hai404 Keystore โ€ฆ nahi mila
Keystore active: false hai403 Keystore โ€ฆ band hai

Keystores โ€” store / edit / delete

MethodPathBody
GET/api/face-scan/keystoresโ€” sab keystores
POST/api/face-scan/keystores{ keystore_id, url, label?, active? } โ€” keystore_id aur url zaroori
GET/api/face-scan/keystores/:keystore_idโ€” ek keystore, hits / last_used_at ke saath
PATCH/api/face-scan/keystores/:keystore_id{ url?, label?, active? } โ€” jo bhejo wahi badlega
DELETE/api/face-scan/keystores/:keystore_idโ€”
# store
curl -X POST http://localhost:3000/api/face-scan/keystores \
     -H 'content-type: application/json' -H "x-passkey: $ADMIN" \
     -d '{"keystore_id":"ks_1001","url":"https://scan.example.com/s/ks_1001","label":"Gate 1"}'

# url badlo
curl -X PATCH http://localhost:3000/api/face-scan/keystores/ks_1001 \
     -H 'content-type: application/json' -H "x-passkey: $ADMIN" \
     -d '{"url":"https://scan.example.com/s/ks_1001_v2"}'

# band karo (delete kiye bina) -- lookup 403 dega
curl -X PATCH http://localhost:3000/api/face-scan/keystores/ks_1001 \
     -H 'content-type: application/json' -H "x-passkey: $ADMIN" \
     -d '{"active":false}'

# sab dekho / hatao
curl http://localhost:3000/api/face-scan/keystorescurl -X DELETE http://localhost:3000/api/face-scan/keystores/ks_1001 -H "x-passkey: $ADMIN"

Create ka response:

{
  "ok": true,
  "data": {
    "keystore_id": "ks_1001",
    "url": "https://scan.example.com/s/ks_1001",
    "label": "Gate 1",
    "active": true,
    "hits": 0,
    "last_used_at": null,
    "created_by": null,
    "created_at": "2026-09-11 10:00:00",
    "updated_at": "2026-09-11 10:00:00"
  }
}

Validation

  • keystore_id โ€” caller deta hai (auto nahi banta), max 200 chars, space / / / control character nahi (path me bhi jaata hai).
  • url โ€” poora http:// ya https:// url, max 2048 chars. javascript:, ftp:, relative path โ€” sab 400.
  • label โ€” optional, max 120 chars.
  • Wahi keystore_id dobara POST kiya โ€” 409, badalna ho to PATCH.

Errors

StatusKab
400keystore_id / url missing ya galat format, invalid JSON
403Keystore band hai (active: false) aur uska lookup kiya
404Keystore nahi mila ยท /api/face-scan/* me aisa route nahi
409Wo keystore_id pehle se store hai

Analytics actions

Face-scan ki har call bhi wahi analytics table me log hoti hai (dashboard ke Request log me dikhti hai), target_id me keystore_id.

  • face_scan.lookup โ€” url lookup
  • face_scan.list, face_scan.get, face_scan.create, face_scan.update, face_scan.delete โ€” store / edit / delete
  • face_scan.disabled โ€” band keystore ka lookup

Table

Core wali SQLite file (DB_PATH) me hi, pehli start par apne aap banti hai.

face_scan_keystores
  keystore_id   TEXT PRIMARY KEY   -- caller deta hai
  url           TEXT NOT NULL      -- lookup par yahi milta hai
  label         TEXT
  active        INTEGER            -- 0 = lookup 403
  hits          INTEGER            -- successful lookups
  last_used_at  TEXT
  created_by    TEXT               -- passkey ke saath banaya ho to uski id, warna null
  created_at    TEXT
  updated_at    TEXT

Code: src/face-scan/store.js (table + validation), src/face-scan/routes.js (saare routes), src/face-scan/docs.html (ye page), src/face-scan/test.js (npm run test:face-scan).