Face Match (1:1)
Within FACIA, the Face Match service takes center stage as a dynamic endpoint, propelling transaction requests into the realm of facial matching algorithms. This innovative algorithm meticulously evaluates the likeness between a Selfie (Photo) and either a Document or another Selfie (Photo), adopting a seamless 1:1 matching approach.
Create Face Match Transaction
This endpoint initiates a transaction request for the face match algorithm, serving as a 1:1 service. The endpoint accepts three fields in the request payload, as mentioned in the request parameters.
Endpoint
POSThttps://api.facia.ai/face-match
Authorization:
Token Type: BearerDescription:
This API utilizes Access token or Client-Secret key in header for authentication.
You can use your client_id and client_secret key when using the "/request-access-token" endpoint to obtain a Bearer token for authorization while connecting to this API. For additional details on Authorization, click Here
Request Body Samples:
- HTTP
- Javascript
- Curl
- PHP
- Python
- Ruby
- Java
- C#
- Go
//POST /face-match HTTP/1.1
//Host: https://api.facia.ai
//Content-Type: application/json
//client-secret: <your client_secret key>
{
"type": "photo_id_match",
"face_frame": "file.jpg",
"id_frame": "file.jpg",
"client_reference": "QWERTY12345",
"allow_override": 0,
"enroll_face":true
}
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
var formdata = new FormData();
formdata.append("type", "photo_id_match");
formdata.append("enroll_face", true);
formdata.append("face_frame", fileInput.files[0], "321238932_678447270428202_3141578377253799698_n.jpeg");
formdata.append("id_frame", fileInput.files[0], "309186968_6430685193624519_4278205846734890662_n.jpeg");
formdata.append("client_reference", "QWERTY12345");
formdata.append("allow_override", false);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("/face-match", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
curl --location 'https://api.facia.ai/face-match' \
--header 'Content-Type: application/json' \
--data '{
"type": "photo_id_match",
"face_frame": file.jpg,
"id_frame": file.jpg,
"client_reference":"QWERTY12345",
"allow_override":false,
"enroll_face": true
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/face-match',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('client_reference'=>'QWERT12345','allow_override'=> false,'enroll_face'=>true,'face_frame'=> new CURLFILE('/321238932_678447270428202_3141578377253799698_n.jpeg'),'id_frame'=> new CURLFILE('/309186968_6430685193624519_4278205846734890662_n.jpeg')),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer token'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/face-match"
payload={'client_reference': 'QWERTY12345','allow_override':false,'enroll_face':false}
files=[
('face_frame',('321238932_678447270428202_3141578377253799698_n.jpeg',open('/321238932_678447270428202_3141578377253799698_n.jpeg','rb'),'image/jpeg')),
('id_frame',('309186968_6430685193624519_4278205846734890662_n.jpeg',open('/309186968_6430685193624519_4278205846734890662_n.jpeg','rb'),'image/jpeg'))
]
headers = {
'Authorization': 'Bearer token'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
require 'net/http'
require 'uri'
url = URI.parse('/face-match')
token = 'adasfewadscxz'
payload = {
client_reference: 'QWERTY123456789',
allow_override: false,
enroll_face: false
}
face_frame_path = 'face_frame_path.jpeg'
id_frame_path = 'face_frame_path.jpeg'
face_frame = File.open(face_frame_path, 'rb')
id_frame = File.open(id_frame_path, 'rb')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == 'https'
request = Net::HTTP::Post.new(url.path)
request['Authorization'] = "Bearer #{token}"
# Set the correct Content-Type header for multipart form data
request['Content-Type'] = 'multipart/form-data; boundary=some_boundary_string'
# Continue with setting the form data...
response = http.request(request)
puts "Response Code: #{response.code}"
puts "Response Body: #{response.body}"
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Map;
public class FaceMatchRequest {
public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
String url = "/face-match";
String token = "your_token";
String payload = "{\"client_reference\": \"QWERTY12345\",\"allow_override\": false,\"enroll_face\":true}";
String faceFramePath = "/path/to/321238932_678447270428202_3141578377253799698_n.jpeg";
String idFramePath = "/path/to/309186968_6430685193624519_4278205846734890662_n.jpeg";
Path faceFrameFile = Path.of(faceFramePath);
Path idFrameFile = Path.of(idFramePath);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(url))
.header("Authorization", "Bearer " + token)
.header("Content-Type", "multipart/form-data")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
}
}
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiUrl = "/face-match";
string token = "your_token";
var payload = new
{
client_reference = "QWERTY12345",
allow_override = false,
enroll_face = false
};
string faceFramePath = "/path/to/321238932_678447270428202_3141578377253799698_n.jpeg";
string idFramePath = "/path/to/309186968_6430685193624519_4278205846734890662_n.jpeg";
using (var httpClient = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
formData.Add(new StringContent(payload.client_reference), "client_reference");
formData.Add(new StringContent(payload.allow_override.ToString()), "allow_override");
formData.Add(new StreamContent(File.OpenRead(faceFramePath)), "face_frame", "321238932_678447270428202_3141578377253799698_n.jpeg");
formData.Add(new StreamContent(File.OpenRead(idFramePath)), "id_frame", "309186968_6430685193624519_4278205846734890662_n.jpeg");
var response = await httpClient.PostAsync(apiUrl, formData);
Console.WriteLine($"Response Code: {response.StatusCode}");
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response Body: {responseBody}");
}
}
}
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
apiURL := "/face-match"
token := "your_token"
payload := map[string]interface{}{
"client_reference": "QWERTY12345",
"allow_override": false,
"enroll_face": false
}
faceFramePath := "/path/to/321238932_678447270428202_3141578377253799698_n.jpeg"
idFramePath := "/path/to/309186968_6430685193624519_4278205846734890662_n.jpeg"
var body bytes.Buffer
writer := multipart.NewWriter(&body)
for key, value := range payload {
_ = writer.WriteField(key, fmt.Sprintf("%v", value))
}
files := []string{faceFramePath, idFramePath}
for _, filePath := range files {
file, err := os.Open(filePath)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
defer file.Close()
part, err := writer.CreateFormFile("file", file.Name())
if err != nil {
fmt.Println("Error creating form file:", err)
return
}
_, err = io.Copy(part, file)
if err != nil {
fmt.Println("Error copying file to form:", err)
return
}
}
writer.Close()
request, err := http.NewRequest("POST", apiURL, &body)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
request.Header.Set("Content-Type", writer.FormDataContentType())
request.Header.Set("Authorization", "Bearer "+token)
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer response.Body.Close()
fmt.Println("Response Code:", response.Status)
responseBody, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
fmt.Println("Response Body:", string(responseBody))
}
Request Parameter
Parameters | Description |
---|---|
type | Required: Yes Type: string Example: type=photo_id_match The type must be "photo_id_match". |
face_frame | Required: Yes Type: file Example: face_frame=file File must be of type .jpeg, .jpg or .png. |
id_frame | Required: Yes Type: file Example: id_frame=file File must be of type .jpeg, .jpg or .png. |
client_reference | Required: No Type: string Minimum: 5 characters Maximum: 255 characters Example: client_reference="QWERTY12345" Required if allow_override field set to 1. |
allow_override | Required: No Type: boolean Default value: 0 Accepted values: 0,1 The client reference is mandatory if the value of the override key is set as 1. The override key allow the system to replace the latest previous image with the new one against the specified reference number of the client’s reference. |
enroll_face | Required: No Type: boolean Example: enroll_face=true Default value: true If you do not want the system to enroll the face then set the value of the key as false. |
Response Sample
{
"status": true,
"message": "Transaction Created",
"result": {
"data": {
"reference_id": "W4437KIWN0KDM13",
"similarity_status": "1",
"similarity_score": "0.98",
"client_reference": "QWERTY12345"
}
}
}
Response Parameter
Parameters | Description |
---|---|
reference_id | Type: string Example: reference_id=W4437KIWN0KDM13 The unique identifier associated with the created transaction. |
similarity_status | Type: string Example: similarity_status=1 1 means matched and 0 means not matched. |
similarity_score | Type: string Example: similarity_score=0.98 Indicates the calculated similarity score of the images provided. |
client_reference | Type: string Example: client_reference=QWERTY12345 Contains the unique ID defined for the end user. |