Compare with Liveness (Sequential)
Endpointβ
POST https://api.verifik.co/v2/face-recognition/compare-with-liveness
Performs comparison first and, if the comparison meets compare_min_score (or if not provided), proceeds to liveness on the probe with liveness_min_score.
Headersβ
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Paramsβ
| Name | Type | Required | Description |
|---|---|---|---|
probe | string | Yes | Base64 image string for the live capture. |
gallery | string[] | Yes | Array of base64 image strings to compare against. URLs are supported and will be fetched and converted internally. |
search_mode | string | Yes | One of FAST or ACCURATE. |
liveness_min_score | number | No | Liveness threshold; default 0.6 if not provided. |
compare_min_score | number | No | Optional comparison threshold (0.67β0.95). |
cropFace | boolean | No | If true, attempts to crop faces in gallery before comparison. |
Requestβ
- Node.js
- PHP
- Python
- Go
const fetch = require("node-fetch");
async function run() {
const res = await fetch("https://api.verifik.co/v2/face-recognition/compare-with-liveness", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_TOKEN}`,
},
body: JSON.stringify({
probe: "<base64>",
gallery: ["<base64>"],
search_mode: "FAST",
liveness_min_score: 0.6,
compare_min_score: 0.8,
cropFace: true
}),
});
console.log(await res.json());
}
run();
<?php
$ch = curl_init("https://api.verifik.co/v2/face-recognition/compare-with-liveness");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_TOKEN")
]);
$body = json_encode([
"probe" => "<base64>",
"gallery" => ["<base64>"],
"search_mode" => "ACCURATE",
"liveness_min_score" => 0.6,
"compare_min_score" => 0.8,
"cropFace" => true
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os, requests
url = "https://api.verifik.co/v2/face-recognition/compare-with-liveness"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_TOKEN')}"
}
payload = {
"probe": "<base64>",
"gallery": ["<base64>"],
"search_mode": "FAST",
"liveness_min_score": 0.6,
"compare_min_score": 0.8,
"cropFace": True
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload := map[string]interface{}{
"probe": "<base64>",
"gallery": []string{"<base64>"},
"search_mode": "FAST",
"liveness_min_score": 0.6,
"compare_min_score": 0.8,
"cropFace": true,
}
b, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/face-recognition/compare-with-liveness", bytes.NewBuffer(b))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_TOKEN"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
Responseβ
- 200
- 401/403
- 409
- 412
- 500
{
"id": "CWL01",
"data": {
"comparison": {
"score": 0.88
},
"liveness": {
"liveness_score": 0.91,
"min_score": 0.6,
"passed": true
}
},
"signature": {
"message": "Certified by Verifik.co",
"dateTime": "January 16, 2024 3:44 PM"
}
}
{
"message": "Authentication required",
"code": "UNAUTHORIZED"
}
or
{
"message": "token_expired",
"code": "FORBIDDEN"
}
{
"message": "\"search_mode\" is required",
"code": "MissingParameter"
}
{
"message": "only_images_in_base64",
"code": "ERROR"
}
{
"message": "internal_error",
"code": "ERROR"
}
Notesβ
- Comparison is executed first. Only if
compare_min_scoreis not provided or met, liveness is executed onprobe. liveness_min_scoredefaults to 0.6 if not provided.- Gallery supports
httpsURLs and will be downloaded and converted to base64 internally;cropFaceoptionally crops faces before comparison.