API Documentation

Face Verification API

post
https://[face api url]
/compare
Face Verification

Parameter in Response

Name
Type
Description
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

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
// Use default score
2
curl --location -g --request POST 'http://[face api url]/compare' \
3
--header 'apikey: {Your API Key}' \
4
--form '[email protected]"{Your Image File Path 1}"' \
5
--form '[email protected]"{Your Image File Path 2}"'
6
7
// Use score of each company
8
--form 'company="{Your Company Name}"'
9
10
// Use min_score
11
--form 'min_score="{Your Minimun Score}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/compare")
3
.header("apikey", "{Your API Key}")
4
.field("{Your Image File Name 1}", new File("{Your Image File Path 1}"))
5
.field("{Your Image File Name 2}", new File("{Your Image File Path 2}"))
6
7
//Use default score
8
//.field("company", "{Your Company Name}")
9
//.field("min_score", "{Your Minimun Score}")
10
11
// Use score of each company
12
.field("company", "{Your Company Name}")
13
14
// Use min_score
15
.field("min_score", "{Your Minimun Score}")
16
17
.asString();
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/compare',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file1': {
11
'value': fs.createReadStream('{Your Image File Path 1}'),
12
'options': {
13
'filename': '{Your Image File Name 1}'
14
'contentType': null
15
}
16
},
17
'file2': {
18
'value': fs.createReadStream('{Your Image File Path 2}'),
19
'options': {
20
'filename': '{Your Image File Name 2}'
21
'contentType': null
22
}
23
},
24
25
// Use default score
26
//'company': '{Your Company Name}'
27
//'min_score': '{Your Minimun Score}'
28
29
// Use score of each company
30
'company': '{Your Company Name}'
31
32
// Use min_score score
33
'min_score': '{Your Minimun Score}'
34
}
35
};
36
request(options, function (error, response) {
37
if (error) throw new Error(error);
38
console.log(response.body);
39
});
40
Copied!
1
#import <Foundation/Foundation.h>
2
3
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
4
5
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://%5Bface%20api%20url%5D/compare"]
6
cachePolicy:NSURLRequestUseProtocolCachePolicy
7
timeoutInterval:10.0];
8
NSDictionary *headers = @{
9
@"apikey": @"{Your API Key}"
10
};
11
12
[request setAllHTTPHeaderFields:headers];
13
NSArray *parameters = @[
14
15
// Use default score
16
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
17
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" }
18
19
// Use score of each company
20
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
21
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" },
22
@{ @"name": @"company", @"value": @"{Your Company Name}" }
23
24
// Use min_score score
25
@{ @"name": @"min_score", @"value": @"{Your Minimun Score}" }
26
@{ @"name": @"file1", @"fileName": @"{Your Image File Path 1}" },
27
@{ @"name": @"file2", @"fileName": @"{Your Image File Path 2}" }
28
29
];
30
31
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
32
NSError *error;
33
NSMutableString *body = [NSMutableString string];
34
35
for (NSDictionary *param in parameters) {
36
[body appendFormat:@"--%@\r\n", boundary];
37
if (param[@"fileName"]) {
38
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
39
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
40
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
41
if (error) {
42
NSLog(@"%@", error);
43
}
44
} else {
45
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
46
[body appendFormat:@"%@", param[@"value"]];
47
}
48
}
49
[body appendFormat:@"\r\n--%@--\r\n", boundary];
50
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
51
[request setHTTPBody:postData];
52
53
[request setHTTPMethod:@"POST"];
54
55
NSURLSession *session = [NSURLSession sharedSession];
56
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
57
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
58
if (error) {
59
NSLog(@"%@", error);
60
dispatch_semaphore_signal(sema);
61
} else {
62
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
63
NSError *parseError = nil;
64
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
65
NSLog(@"%@",responseDictionary);
66
dispatch_semaphore_signal(sema);
67
}
68
}];
69
[dataTask resume];
70
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
Copied!
1
<?php
2
require_once 'HTTP/Request2.php';
3
$request = new HTTP_Request2();
4
$request->setUrl('http://[face api url]/compare');
5
$request->setMethod(HTTP_Request2::METHOD_POST);
6
$request->setConfig(array(
7
'follow_redirects' => TRUE
8
));
9
$request->setHeader(array(
10
'apikey' => '{Your API Key}'
11
));
12
13
// Use default score
14
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
15
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
16
17
// Use score of each company
18
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
19
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
20
$request->addPostParameter(array(
21
'company' => '{Your Company Name}'
22
));
23
24
// Use score of each company
25
$request->addUpload('file1', '{Your Image File Path 1}', '{Your Image File Name 1}', '<Content-Type Header>');
26
$request->addUpload('file2', '{Your Image File Path 2}', '{Your Image File Name 2}', '<Content-Type Header>');
27
$request->addPostParameter(array(
28
'min_score' => '{Your Minimun Score}'
29
));
30
31
try {
32
$response = $request->send();
33
if ($response->getStatus() == 200) {
34
echo $response->getBody();
35
}
36
else {
37
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
38
$response->getReasonPhrase();
39
}
40
}
41
catch(HTTP_Request2_Exception $e) {
42
echo 'Error: ' . $e->getMessage();
43
}
Copied!
1
import requests
2
3
url = "http://[face api url]/compare"
4
5
# Use default score
6
payload={}
7
8
# Use score of each company
9
payload={'company': '{Your Company Name}'}
10
11
# Use default score
12
payload={'min_score': '{Your Minimun Score}'}
13
14
files=[
15
('file1',('{Your Image File Name 1}',open('{Your Image File Path 1}','rb'),'application/octet-stream')),
16
('file2',('{Your Image File Name 2}',open('{Your Image File Path 2}','rb'),'application/octet-stream'))
17
]
18
headers = {
19
'apikey': '{Your API Key}'
20
}
21
22
response = requests.request("POST", url, headers=headers, data=payload, files=files)
23
24
print(response.text)
Copied!

Face Verification Tool

get
https://[face api url]
/config
Default Score Configuration

Parameter in Response

Name
Type
Description
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

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
// Configure Score
2
curl --location -g --request GET 'https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}' \
3
--header 'apikey: {Your API Key}'
4
5
// Configure Score
6
curl --location -g --request GET 'https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}' \
7
--header 'apikey: {Your API Key}'
Copied!
1
Unirest.setTimeouts(0, 0);
2
3
// Configure Score
4
HttpResponse<String> response = Unirest.get("https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}")
5
.header("apikey", "{Your API Key}")
6
.multiPartContent()
7
.asString();
8
9
// Configure Score
10
HttpResponse<String> response = Unirest.get("https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}")
11
.header("apikey", "{Your API Key}")
12
.multiPartContent()
13
.asString();
Copied!
1
var request = require('request');
2
var options = {
3
'method': 'GET',
4
5
// Configure Score
6
'url': 'https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}',
7
8
// Configure Score
9
'url': 'https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}',
10
11
'headers': {
12
'apikey': '{Your API Key}'
13
},
14
formData: {
15
16
}
17
};
18
request(options, function (error, response) {
19
if (error) throw new Error(error);
20
console.log(response.body);
21
});
22
Copied!
1
#import <Foundation/Foundation.h>
2
3
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
4
5
// Configure Score
6
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}"]
7
cachePolicy:NSURLRequestUseProtocolCachePolicy
8
timeoutInterval:10.0];
9
10
// Show Score
11
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}"]
12
cachePolicy:NSURLRequestUseProtocolCachePolicy
13
timeoutInterval:10.0];
14
15
NSDictionary *headers = @{
16
@"apikey": @"{Your API Key}"
17
};
18
19
[request setAllHTTPHeaderFields:headers];
20
21
[request setHTTPMethod:@"GET"];
22
23
NSURLSession *session = [NSURLSession sharedSession];
24
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
25
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
26
if (error) {
27
NSLog(@"%@", error);
28
dispatch_semaphore_signal(sema);
29
} else {
30
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
31
NSError *parseError = nil;
32
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
33
NSLog(@"%@",responseDictionary);
34
dispatch_semaphore_signal(sema);
35
}
36
}];
37
[dataTask resume];
38
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
Copied!
1
<?php
2
require_once 'HTTP/Request2.php';
3
$request = new HTTP_Request2();
4
5
// Configure Score
6
$request->setUrl('https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}');
7
8
// Show Score
9
$request->setUrl('https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}');
10
11
$request->setMethod(HTTP_Request2::METHOD_GET);
12
$request->setConfig(array(
13
'follow_redirects' => TRUE
14
));
15
$request->setHeader(array(
16
'apikey' => '{Your API Key}'
17
));
18
try {
19
$response = $request->send();
20
if ($response->getStatus() == 200) {
21
echo $response->getBody();
22
}
23
else {
24
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
25
$response->getReasonPhrase();
26
}
27
}
28
catch(HTTP_Request2_Exception $e) {
29
echo 'Error: ' . $e->getMessage();
30
}
Copied!
1
import requests
2
3
# Configure Score
4
url = "https://[face api url]/config?detection={Detection Value}&comparison={Comparison Value}&company={Your Company Name}&password={Your Company Password}"
5
6
# Show Score
7
url = "https://[face api url]/config?detection&comparison&company={Your Company Name}&password={Your Company Password}"
8
9
payload={}
10
files={}
11
headers = {
12
'apikey': '{Your API Key}'
13
}
14
15
response = requests.request("GET", url, headers=headers, data=payload, files=files)
16
17
print(response.text)
Copied!
Last modified 1mo ago