API Documentation

Face Recognition API

post
https://[face api url]
/recog/single
Face Recognition For Single Face

Parameter in Response

Name
Type
Description
bbox
Dictionary
Face bounding boxes of personal
xmax
Float
Maximum value in the x-axis
xmin
Float
Minimum value in the x-axis
ymax
Float
Maximum value in the y-axis
ymin
Float
Minimum value in the y-axis
company
String
The company name
detection_score
String
Detection score of face in image.
message
String
The processing status
name
String
The personal name
process_time
Float
The processing time
recognition_score
Float
Recognition score of face in image.

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
curl --location -g --request POST 'http://[face api url]/recog/single' \
2
--header 'apikey: {Your API Key}' \
3
--form 'company="{Your Company Name}"' \
4
--form '[email protected]"{Your Image File Path}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/recog/single")
3
.header("apikey", "{Your API Key}")
4
.field("file", new File("{Your Image File Path}"))
5
.field("company", "{Your Company Name}")
6
.asString();
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/recog/single',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('{Your Image File Path}'),
12
'options': {
13
'filename': '{Your Image File Name}'
14
'contentType': null
15
}
16
},
17
'company': '{Your Company Name}'
18
}
19
};
20
request(options, function (error, response) {
21
if (error) throw new Error(error);
22
console.log(response.body);
23
});
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://[face api url]/recog/single"]
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
@{ @"name": @"file", @"fileName": @"{Your Image File Path}" },
15
@{ @"name": @"company", @"value": @"{Your Company Name}" }
16
];
17
18
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
19
NSError *error;
20
NSMutableString *body = [NSMutableString string];
21
22
for (NSDictionary *param in parameters) {
23
[body appendFormat:@"--%@\r\n", boundary];
24
if (param[@"fileName"]) {
25
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
26
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
27
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
28
if (error) {
29
NSLog(@"%@", error);
30
}
31
} else {
32
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
33
[body appendFormat:@"%@", param[@"value"]];
34
}
35
}
36
[body appendFormat:@"\r\n--%@--\r\n", boundary];
37
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
38
[request setHTTPBody:postData];
39
40
[request setHTTPMethod:@"POST"];
41
42
NSURLSession *session = [NSURLSession sharedSession];
43
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
44
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
45
if (error) {
46
NSLog(@"%@", error);
47
dispatch_semaphore_signal(sema);
48
} else {
49
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
50
NSError *parseError = nil;
51
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
52
NSLog(@"%@",responseDictionary);
53
dispatch_semaphore_signal(sema);
54
}
55
}];
56
[dataTask resume];
57
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]/recog/single');
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
$request->addPostParameter(array(
13
'company' => '{Your Company Name}'
14
));
15
$request->addUpload('file', '{Your Image File Path}', '{Your Image File Name}', '<Content-Type Header>');
16
try {
17
$response = $request->send();
18
if ($response->getStatus() == 200) {
19
echo $response->getBody();
20
}
21
else {
22
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
23
$response->getReasonPhrase();
24
}
25
}
26
catch(HTTP_Request2_Exception $e) {
27
echo 'Error: ' . $e->getMessage();
28
}
Copied!
1
import requests
2
3
url = "http://[face api url]/recog/single"
4
5
payload={'company': '{Your Company Name}'}
6
files=[
7
('file',('{Your Image File Name}',open('{Your Image File Path}','rb'),'image/jpeg'))
8
]
9
headers = {
10
'apikey': '{Your API Key}'
11
}
12
13
response = requests.request("POST", url, headers=headers, data=payload, files=files)
14
15
print(response.text)
Copied!
post
https://[face api url]
/recog/multi
Face Recognition For Multiple Face

Parameter in Response

Name
Type
Description
message
String
The processing status
process_time
Float
The processing time
result
Array
The data in dictionary for each personal
bbox
Dictionary
Face bounding boxes of personal
xmax
Float
Maximum value in the x-axis
xmin
Float
Minimum value in the x-axis
ymax
Float
Maximum value in the y-axis
ymin
Float
Minimum value in the y-axis
company
String
The company name
detection_score
Float
Detection score of face in image.
name
String
The personal name
recognition_score
Float
Recognition score of face in image.

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
curl --location -g --request POST 'http://[face api url]/recog/multi' \
2
--header 'apikey: {Your API Key}' \
3
--form 'company="{Your Company Name}"' \
4
--form '[email protected]"{Your Image File Path}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/recog/multi")
3
.header("apikey", "{Your API Key}")
4
.field("file", new File("{Your Image File Path}"))
5
.field("company", "{Your Company Name}")
6
.asString();
7
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/recog/multi',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('{Your Image File Path}'),
12
'options': {
13
'filename': '{Your Image File Name}'
14
'contentType': null
15
}
16
},
17
'company': '{Your Company Name}'
18
}
19
};
20
request(options, function (error, response) {
21
if (error) throw new Error(error);
22
console.log(response.body);
23
});
24
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://[face api url]/recog/multi"]
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
@{ @"name": @"file", @"fileName": @"{Your Image File Path}" },
15
@{ @"name": @"company", @"value": @"{Your Company Name}" }
16
];
17
18
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
19
NSError *error;
20
NSMutableString *body = [NSMutableString string];
21
22
for (NSDictionary *param in parameters) {
23
[body appendFormat:@"--%@\r\n", boundary];
24
if (param[@"fileName"]) {
25
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
26
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
27
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
28
if (error) {
29
NSLog(@"%@", error);
30
}
31
} else {
32
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
33
[body appendFormat:@"%@", param[@"value"]];
34
}
35
}
36
[body appendFormat:@"\r\n--%@--\r\n", boundary];
37
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
38
[request setHTTPBody:postData];
39
40
[request setHTTPMethod:@"POST"];
41
42
NSURLSession *session = [NSURLSession sharedSession];
43
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
44
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
45
if (error) {
46
NSLog(@"%@", error);
47
dispatch_semaphore_signal(sema);
48
} else {
49
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
50
NSError *parseError = nil;
51
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
52
NSLog(@"%@",responseDictionary);
53
dispatch_semaphore_signal(sema);
54
}
55
}];
56
[dataTask resume];
57
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]/recog/multi');
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
$request->addPostParameter(array(
13
'company' => '{Your Company Name}'
14
));
15
$request->addUpload('file', '{Your Image File Path}', '{Your Image File Name}', '<Content-Type Header>');
16
try {
17
$response = $request->send();
18
if ($response->getStatus() == 200) {
19
echo $response->getBody();
20
}
21
else {
22
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
23
$response->getReasonPhrase();
24
}
25
}
26
catch(HTTP_Request2_Exception $e) {
27
echo 'Error: ' . $e->getMessage();
28
}
Copied!
1
import requests
2
3
url = "http://[face api url]/recog/multi"
4
5
payload={'company': '{Your Company Name}'}
6
files=[
7
('file',('{Your Image File Name}',open('{Your Image File Path}','rb'),'image/jpeg'))
8
]
9
headers = {
10
'apikey': '{Your API Key}'
11
}
12
13
response = requests.request("POST", url, headers=headers, data=payload, files=files)
14
15
print(response.text)
Copied!
post
https://[face api url]
/recog/face
Face Recognition For Only Face

Parameter in Response

Name
Type
Description
company
String
The company name
message
String
The processing status
name
String
The personal name
process_time
Float
The processing time
recognition_score
Float
Recognition score of face in image.

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
curl --location -g --request POST 'http://[face api url]/recog/face' \
2
--header 'apikey: {Your API Key}' \
3
--form 'company="{Your Company Name}"' \
4
--form '[email protected]"{Your Image File Path}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/recog/face")
3
.header("apikey", "{Your API Key}")
4
.field("file", new File("{Your Image File Path}"))
5
.field("company", "{Your Company Name}")
6
.asString();
7
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/recog/face',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('{Your Image File Path}'),
12
'options': {
13
'filename': '{Your Image File Name}'
14
'contentType': null
15
}
16
},
17
'company': '{Your Company Name}'
18
}
19
};
20
request(options, function (error, response) {
21
if (error) throw new Error(error);
22
console.log(response.body);
23
});
24
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://[face api url]/recog/face"]
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
@{ @"name": @"file", @"fileName": @"{Your Image File Path}" },
15
@{ @"name": @"company", @"value": @"{Your Company Name}" }
16
];
17
18
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
19
NSError *error;
20
NSMutableString *body = [NSMutableString string];
21
22
for (NSDictionary *param in parameters) {
23
[body appendFormat:@"--%@\r\n", boundary];
24
if (param[@"fileName"]) {
25
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
26
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
27
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
28
if (error) {
29
NSLog(@"%@", error);
30
}
31
} else {
32
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
33
[body appendFormat:@"%@", param[@"value"]];
34
}
35
}
36
[body appendFormat:@"\r\n--%@--\r\n", boundary];
37
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
38
[request setHTTPBody:postData];
39
40
[request setHTTPMethod:@"POST"];
41
42
NSURLSession *session = [NSURLSession sharedSession];
43
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
44
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
45
if (error) {
46
NSLog(@"%@", error);
47
dispatch_semaphore_signal(sema);
48
} else {
49
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
50
NSError *parseError = nil;
51
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
52
NSLog(@"%@",responseDictionary);
53
dispatch_semaphore_signal(sema);
54
}
55
}];
56
[dataTask resume];
57
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]/recog/face');
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
$request->addPostParameter(array(
13
'company' => '{Your Company Name}'
14
));
15
$request->addUpload('file', '{Your Image File Path}', '{Your Image File Name}', '<Content-Type Header>');
16
try {
17
$response = $request->send();
18
if ($response->getStatus() == 200) {
19
echo $response->getBody();
20
}
21
else {
22
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
23
$response->getReasonPhrase();
24
}
25
}
26
catch(HTTP_Request2_Exception $e) {
27
echo 'Error: ' . $e->getMessage();
28
}
Copied!
1
import requests
2
3
url = "http://[face api url]/recog/face"
4
5
payload={'company': '{Your Company Name}'}
6
files=[
7
('file',('{Your Image File Name}',open('{Your Image File Path}','rb'),'image/jpeg'))
8
]
9
headers = {
10
'apikey': '{Your API Key}'
11
}
12
13
response = requests.request("POST", url, headers=headers, data=payload, files=files)
14
15
print(response.text)
Copied!

Face Recognition Tool

post
https://[face api url]
/recog/add
Adding Face

Parameter in Response

Name
Type
Description
company
String
The company name
face
String
Face image in base64 format
face_id
String
The ID of face for remove
message
String
The processing status
name
String
The personal name

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
curl --location -g --request POST 'http://[face api url]/recog/add' \
2
--header 'apikey: {Your API Key}' \
3
--form '[email protected]"{Your Image File Path}"' \
4
--form 'company="{Your Company Name}"' \
5
--form 'name="{Personal Name}"' \
6
--form 'password="{Your Company Password}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/recog/add")
3
.header("apikey", "{Your API Key}")
4
.field("file", new File("{Your Image File Path}"))
5
.field("company", "{Your Company Name}")
6
.field("name", "{Personal Name}")
7
.field("password", "{Your Company Password}")
8
.asString();
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/recog/add',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('{Your Image File Path}'),
12
'options': {
13
'filename': '{Your Image File Name}',
14
'contentType': null
15
}
16
},
17
'company': '{Your Company Name}',
18
'name': '{Personal Name}',
19
'password': '{Your Company Password}'
20
}
21
};
22
request(options, function (error, response) {
23
if (error) throw new Error(error);
24
console.log(response.body);
25
});
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://[face api url]/recog/add"]
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
@{ @"name": @"file", @"fileName": @"{Your Image File Path}" },
15
@{ @"name": @"company", @"value": @"{Your Company Name}" },
16
@{ @"name": @"name", @"value": @"{Personal Name}" },
17
@{ @"name": @"password", @"value": @"{Your Company Password}" }
18
];
19
20
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
21
NSError *error;
22
NSMutableString *body = [NSMutableString string];
23
24
for (NSDictionary *param in parameters) {
25
[body appendFormat:@"--%@\r\n", boundary];
26
if (param[@"fileName"]) {
27
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
28
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
29
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
30
if (error) {
31
NSLog(@"%@", error);
32
}
33
} else {
34
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
35
[body appendFormat:@"%@", param[@"value"]];
36
}
37
}
38
[body appendFormat:@"\r\n--%@--\r\n", boundary];
39
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
40
[request setHTTPBody:postData];
41
42
[request setHTTPMethod:@"POST"];
43
44
NSURLSession *session = [NSURLSession sharedSession];
45
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
46
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
47
if (error) {
48
NSLog(@"%@", error);
49
dispatch_semaphore_signal(sema);
50
} else {
51
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
52
NSError *parseError = nil;
53
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
54
NSLog(@"%@",responseDictionary);
55
dispatch_semaphore_signal(sema);
56
}
57
}];
58
[dataTask resume];
59
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]/recog/add');
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
$request->addPostParameter(array(
13
'company' => '{Your Company Name}',
14
'name' => '{Personal Name}',
15
'password' => '{Your Company Password}'
16
));
17
$request->addUpload('file', '{Your Image File Path}', '<Content-Type Header>');
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
url = "http://[face api url]/recog/add"
4
5
payload={'company': '{Your Company Name}',
6
'name': '{Personal Name}',
7
'password': '{Your Company Password}'}
8
files=[
9
('file',('{Your Image File Name}',open('{Your Image File Path}','rb'),'image/jpeg'))
10
]
11
headers = {
12
'apikey': '{Your API Key}'
13
}
14
15
response = requests.request("POST", url, headers=headers, data=payload, files=files)
16
17
print(response.text)
Copied!
post
https://[face api url]
/recog/import
Importing Feature File

Parameter in Response

Name
Type
Description
company
String
The company name
face
String
Face image in base64 format
face_id
String
The ID of face for remove
message
String
The processing status
name
String
The personal name

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python
1
curl --location -g --request POST 'http://[face api url]/recog/import' \
2
--header 'apikey: {Your API Key}' \
3
--form '[email protected]"{Your Feature CSV FIle Path}"' \
4
--form 'company="{Your Company Name}"' \
5
--form 'password="{Your Company Password}"'
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("http://[face api url]/recog/import")
3
.header("apikey", "{Your API Key}")
4
.field("file", new File("{Your Feature CSV FIle Path}"))
5
.field("company", "{Your Company Name}")
6
.field("password", "{Your Company Password}")
7
.asString();
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'http://[face api url]/recog/import',
6
'headers': {
7
'apikey': '{Your API Key}'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('{Your Feature CSV File Path}'),
12
'options': {
13
'filename': '{Your Feature CSV File Name}',
14
'contentType': null
15
}
16
},
17
'company': '{Your Company Name}',
18
'password': '{Your Company Password}'
19
}
20
};
21
request(options, function (error, response) {
22
if (error) throw new Error(error);
23
console.log(response.body);
24
});
25
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://[face api url]/recog/import"]
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
@{ @"name": @"file", @"fileName": @"{Your Feature CSV FIle Path}" },
15
@{ @"name": @"company", @"value": @"{Your Company Name}" },
16
@{ @"name": @"password", @"value": @"{Your Company Password}" }
17
];
18
19
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
20
NSError *error;
21
NSMutableString *body = [NSMutableString string];
22
23
for (NSDictionary *param in parameters) {
24
[body appendFormat:@"--%@\r\n", boundary];
25
if (param[@"fileName"]) {
26
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
27
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
28
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
29
if (error) {
30
NSLog(@"%@", error);
31
}
32
} else {
33
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
34
[body appendFormat:@"%@", param[@"value"]];
35
}
36
}
37
[body appendFormat:@"\r\n--%@--\r\n", boundary];
38
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
39
[request setHTTPBody:postData];
40
41
[request setHTTPMethod:@"POST"];
42
43
NSURLSession *session = [NSURLSession sharedSession];
44
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
45
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
46
if (error) {
47
NSLog(@"%@", error);
48
dispatch_semaphore_signal(sema);
49
} else {
50
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
51
NSError *parseError = nil;
52
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
53
NSLog(@"%@",responseDictionary);
54
dispatch_semaphore_signal(sema);
55
}
56
}];
57
[dataTask resume];
58
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]/recog/import');
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
$request->addPostParameter(array(
13
'company' => '{Your Company Name}',
14
'password' => '{Your Company Password}'
15
));
16
$request->addUpload('file', '/home/once/once/ai/project/face/ai_face_api/feature/test/iApp.csv', 'iApp.csv', '<Content-Type Header>');
17