face-plus-plus
v0.0.3
Published
Node client for faceplusplus.com API
Downloads
12
Maintainers
Readme
face-plus-plus
face-plus-plus is a node client for the faceplusplus.com(CN) API
Version: 0.0.3
Installation via npm
$ npm install face-plus-plus
Require
var fpp = require('face-plus-plus');
Configure face-plus-plus
(Required) Set your API Key
fpp.setApiKey('YOUR_API_KEY');
(Required) Set your API Secret
fpp.setApiSecret('YOUR_API_SECRET');
(Optional) Set the server (default: 'us')
fpp.setServer('cn');
(Optional) Set the API version (default: '2')
fpp.setVersion('2');
(Optional) Set request options
var options = {
timeout: 3000,
headers: { connection: "keep-alive" }
};
fpp.setOptions(options);
Examples
GET request (pass an image at a URL)
var fpp = require('face-plus-plus');
fpp.setApiKey('YOUR_API_KEY');
fpp.setApiSecret('YOUR_API_SECRET');
var parameters = {
url: 'http://example.com/a.jpg',
attribute: 'gender,age'
};
fpp.get('detection/detect', parameters, function(err, res) {
console.log(res);
});
POST request (pass an image from the local file system)
var fpp = require('face-plus-plus'),
fs = require('fs');
fpp.setApiKey('YOUR_API_KEY');
fpp.setApiSecret('YOUR_API_SECRET');
var parameters = {
attribute: 'gender,age',
img : {
value: fs.readFileSync('./a.jpg')
, meta: {filename:'a.jpg'}
}
};
fpp.post('detection/detect', parameters, function(err, res) {
console.log(res);
});