API Documentation
Face Verification API
Face Verification
POST
https://api.iapp.co.th/face_compare
This URL allows you to verify two faces. by submitting the results and scores for the similarity of the two faces.
Headers
apikey*
String
The API Key to call this API
Request Body
file1*
File
The binary data of the image
file2*
File
The binary data of the image
company
String
The company name
min_score
String
The minimum score of face verification for this request
{
"message": "successfully performed",
"process_time": 0.3729121685028076,
"result": "matched",
"similarity_score": 0.5220710916461694
}
{
"message": "successfully performed",
"process_time": 0.2623169422149658,
"result": "not matched",
"similarity_score": 0.052153867628360495
}
Parameter in Response
message
String
The processing status
process_time
Float
The processing time
result
String
The similarity result of verification
similarity_score
Float
The similarity score of verification
Sample Requests
// Use default score
curl --location -g --request POST 'https://api.iapp.co.th/face_compare' \
--header 'apikey: {Your API Key}' \
--form 'file1=@"{Your Image File Path 1}"' \
--form 'file2=@"{Your Image File Path 2}"'
// Use score of each company
--form 'company="{Your Company Name}"'
// Use min_score
--form 'min_score="{Your Minimun Score}"'
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/face_compare")
.header("apikey", "{Your API Key}")
.field("{Your Image File Name 1}", new File("{Your Image File Path 1}"))
.field("{Your Image File Name 2}", new File("{Your Image File Path 2}"))
//Use default score
//.field("company", "{Your Company Name}")
//.field("min_score", "{Your Minimun Score}")
// Use score of each company
.field("company", "{Your Company Name}")
// Use min_score
.field("min_score", "{Your Minimun Score}")
.asString();
var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/face_compare',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
'file1': {
'value': fs.createReadStream('{Your Image File Path 1}'),
'options': {
'filename': '{Your Image File Name 1}'
'contentType': null
}
},
'file2': {
'value': fs.createReadStream('{Your Image File Path 2}'),
'options': {
'filename': '{Your Image File Name 2}'
'contentType': null
}
},
// Use default score
//'company': '{Your Company Name}'
//'min_score': '{Your Minimun Score}'
// Use score of each company
'company': '{Your Company Name}'
// Use min_score score
'min_score': '{Your Minimun Score}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/face_compare"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
[request setAllHTTPHeaderFields:headers];
NSArray *parameters = @[
// Use default score
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" }
// Use score of each company
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" },
@{ @"name": @"company", @"value": @"{Your Company Name}" }
// Use min_score score
@{ @"name": @"min_score", @"value": @"{Your Minimun Score}" }
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" }
];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/face_compare');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
// Use default score
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
// Use score of each company
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
$request->addPostParameter(array(
'company' => '{Your Company Name}'
));
// Use score of each company
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
$request->addPostParameter(array(
'min_score' => '{Your Minimun Score}'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import requests
url = "https://api.iapp.co.th/face_compare"
# Use default score
payload={}
# Use score of each company
payload={'company': '{Your Company Name}'}
# Use default score
payload={'min_score': '{Your Minimun Score}'}
files=[
('file1',('{Your Image File Name 1}',open('{Your Image File Path 1}','rb'),'application/octet-stream')),
('file2',('{Your Image File Name 2}',open('{Your Image File Path 2}','rb'),'application/octet-stream'))
]
headers = {
'apikey': '{Your API Key}'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Face Verification Tool
Default Score Configuration
GET
https://api.iapp.co.th/face_config_score
This URL be for configure the default score of face verification for each company or check the default score
Query Parameters
detection*
String
The default score of detection
comparison*
String
The default score of verification
company*
String
The name of customer company
password*
String
The password of customer company
Headers
apikey*
String
The API Key to call this API
{
"company": "iApp",
"comparison_score": 0.4,
"detection_score": 0.98,
"message": "the minimum score of comparison has been successfully configured.",
}
{
"company": "iApp",
"comparison_score": 0.4,
"detection_score": 0.97,
"message": "the minimum score has been successfully shown."
}
Parameter in Response
company
String
The company name
comparison_score
Float
The default score of comparison
detection_score
Float
The default score of detection
message
String
The Processing status
Sample Requests
// Configure Score
curl --location -g --request GET 'https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}' \
--header 'apikey: {Your API Key}'
// Show Score
curl --location -g --request GET 'https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}' \
--header 'apikey: {Your API Key}'
Unirest.setTimeouts(0, 0);
// Configure Score
HttpResponse<String> response = Unirest.get("https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}")
.header("apikey", "{Your API Key}")
.multiPartContent()
.asString();
// Show Score
HttpResponse<String> response = Unirest.get("https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}")
.header("apikey", "{Your API Key}")
.multiPartContent()
.asString();
var request = require('request');
var options = {
'method': 'GET',
// Configure Score
'url': 'https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}',
// Show Score
'url': 'https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
// Configure Score
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
// Show Score
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
[request setAllHTTPHeaderFields:headers];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
// Configure Score
$request->setUrl('https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}');
// Show Score
$request->setUrl('https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import requests
# Configure Score
url = "https://api.iapp.co.th/face_config_score?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}"
# Show Score
url = "https://api.iapp.co.th/face_config_score?detection&comparison&company={Your Company Name}&password={Your Company Password}"
payload={}
files={}
headers = {
'apikey': '{Your API Key}'
}
response = requests.request("GET", url, headers=headers, data=payload, files=files)
print(response.text)
Last updated