Face Recognition API

Introduction

The Bitband Face Recognition API allows ML engineers and software developers to easily analyze face images to understand identifying characteristics, emotions, and many other details.

Getting Started

Find below sample code for getting started with the Face Recognition API.

PHP

//php
$client = new\GuzzleHttp\Client();
$filePath = 'testImage.jpg';
$response = $client->request('POST', 'https://api.bitband.com/v1/image-info', [
'multipart' => [
[
'name' => 'image',
'contents' => fopen($filePath, 'r'),
],
],
'headers' => [
'apiKey' => 'YOUR_API_TOKEN',
],
]);

JavaScript (node.js)

//nodejs
const request = require('request')
var formData = {
image: fs.createReadStream('testImage.jpg')
};
request.post({
url: 'https://api.bitband.com/v1/image-info',
headers: {
'apiKey': 'YOUR_API_TOKEN',
}, formData: formData
}, function optionalCallback(err, httpResponse, body) {
})

Ruby

//Ruby
require'faraday'
conn =
Faraday.new do |f|
f.request :multipart
f.request :url_encoded
f.adapter :net_http
end
conn.headers = {'apiKey': 'YOUR_API_TOKEN'}
file_io = {'image': Faraday::UploadIO.new('testImage.jpg', 'image/jpeg')}
conn.post('https://api.bitband.com/v1/image-info', file: file_io)

Python

//Python
import requests
url = 'https://api.bitband.com/v1/image-info'
files = {'image': open('testImage.jpg', 'rb')}
headers = {'apiKey': 'YOUR_API_TOKEN'}
r = requests.post(url, files=files, headers=headers)

Go

//Go
func SendPostRequest(url string, filename string) (string, []byte) {
client := &http.Client{}
data, err := os.Open(filename)
if err != nil {
log.Fatal(err)
}
req, err := http.NewRequest("POST", url, data)
if err != nil {
log.Fatal(err)
}
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
return resp.Status, content
}
func main() {
status, content := SendPostRequest("https://api.bitband.com/v1/image-info","testImage.jpg")
fmt.Println(status)
fmt.Println(string(content))
}