Face2Face
Description#
Face 2 Face - is a service for comparing two faces. The service gives the result in the form of the percentage of similarity of faces in fractional and percentage ratio.
To use this service, you need to have the organization's API-KEY, as well as two photos of faces for comparison.
The stepsfor using this technology are described in more detail below. You can also check the OpenAPI-specification of all available technologies to use.
Stages:#
1. Obtaining API-KEY of the organization#
The first step to use the technology is to obtain the organization's API-KEY. To get the organization's API-KEY, you need to go to Personal Cabinet by following this link. API-KEY is in the Backend Api Key field.
An example of an organization's API-KEY:
API-KEY: Efy202XKbVAWRu...
Note
The shortened length of the
API KEY
is used for clarity. Its actual length is 47 characters or more.
2. Sending a facial comparison request#
Data in multipart/form-data format is used in requests to our service. The response data from the service will be presented in JSON format.
Important
To use this service, you must have a subscription to it. You can read more about subscriptions here.
Request URL:
https://kyc.biometric.kz/api/v1/backend/face2face/compare/
Request format | Request method |
---|---|
multipart/form-data | POST |
API KEY
must be passed in the request body:
Field name | Type | Obligatorily | Description |
---|---|---|---|
api_key | String | Да | API KEY of the organization in the personal cabinet |
img_1 | File | Да | First picture of the face |
img_2 | File | Да | Second picture of the face |
Request examples:
curl -X 'POST' \
'https://kyc.biometric.kz/api/v1/backend/face2face/compare/' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'img_1=@<path_to_face_photo_1;type=image/<image_extension>' \
-F 'img_2=@<path_to_face_photo_2;type=image/<image_extension>' \
-F 'api_key=<organization_api_key>'
import requests
url = 'https://kyc.biometric.kz/api/v1/backend/face2face/compare/'
headers = {
'accept': 'application/json',
}
face_path_1 = "<path_to_face_photo_1>"
face_path_2 = "<path_to_face_photo_2>"
files = {
'img_1': (face_path_1, open(face_path_1, 'rb'), 'image/<image_extension>'),
'img_2': (face_path_2, open(face_path_2, 'rb'), 'image/<image_extension>'),
}
data = {
'api_key': '<organization_api_key>',
}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
/*
dependencies to install via npm:
form-data, fs, node-fetch
*/
import FormData from 'form-data';
import fs from 'fs';
import fetch from 'node-fetch';
const face_path_1 = "<path_to_face_photo_1>";
const face_path_2 = "<path_to_face_photo_2>";
const url = 'https://kyc.biometric.kz/api/v1/backend/face2face/compare/';
const apiKey = '<organization_api_key>';
const formData = new FormData();
formData.append('img_1', fs.createReadStream(face_path_1));
formData.append('img_2', fs.createReadStream(face_path_2));
formData.append('api_key', apiKey);
fetch(url, {
method: 'POST',
headers: {
'accept': 'application/json',
},
body: formData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
The response will be JSON with the following fields:
- result - result of comparing two faces;
- prediction - fractional similarity value of two faces;
- prediction_percent - percentage similarity of two faces.
Response example:
Errors#
Код состояния | Response | Description |
---|---|---|
400 | No face found | No face found. Occurs if there is no face in the photo |
400 | Can`t connect to face2face service | Failed to connect to face2face service |
400 | Client does not have access to Face2Face technology | Client does not have access to the technology. Reasons: No subscription, or it has expired, or the technology is not active |
400 | Face2Face result does not exist | No result, send photo comparison request |
415 | Not allowed file, valid extensions: .jpg .png .jpeg | Invalid file extension, valid: .jpg .png .jpeg |
400 | Subscription has not started | Subscription has not been activated yet |
400 | No active or future subscription for technology | No active or future subscription to the technology |
400 | Client does not have subscription | Client does not have a subscription, you can read more about subscriptions here |