Links

API Documentation

Face Verification API

post
https://api.iapp.co.th/face-verification
/v2/face_compare
This URL allows you to verify two faces. by submitting the results and scores for the similarity of the two faces.

Parameter in Response

Name
Type
Description
duration
Float
The processing time
matched
Boolean
The similarity result of verification
message
String
The status message
score
Intergal
The similarity score of verification
threshold
Intergal
The threshold of verification score of profile name

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
curl --location --request POST 'https://api.iapp.co.th/face-verification/v2/face_compare' \
--header 'apikey: {Your API Key}' \
--form 'file1=@"{Your Image File Path 1}"' \
--form 'file2=@"{Your Image File Path 2}"'
var unirest = require('unirest');
var req = unirest('POST', 'https://api.iapp.co.th/face-verification/v2/face_compare')
.headers({
'apikey': '{Your API Key}'
})
.attach('file1', '{Your Image File Path 1}')
.attach('file2', '{Your Image File Path 2}')
.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/face-verification/v2/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
}
}
}
};
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-verification/v2/face_compare"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
[request setAllHTTPHeaderFields:headers];
NSArray *parameters = @[
@{ @"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-verification/v2/face_compare');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
$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>');
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-verification/v2/face_compare"
payload={}
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)