Illustration symbolizing Rapid API and Kairos Face Recognition

 

Application Program Interfaces (API) have been around since the early 2000s yet the marketplace for them has had immense growth within the last few years. The growth has been so rapid that a library of APIs has been a major wish list item for developers.

 

Iddo Gino has fulfilled that dev wish with the creation of RapidAPI.com, a marketplace that allows developers to search, find, test, and use all available public APIs within minutes.

RapidAPI.com is not the first company to create this type of library, MuleSoft and ProgrammableWeb has an API directory, yet RapidAPI may be the first ones to do it at a large scale while allowing the user to track and manage all their connected APIs. That is pretty impressive.

 

Why is it Impressive?

We’re going to be blunt - finding the right API for your needs is a real problem. Not only do you have to question the quality of a free API, as it’s usually buggy, but you also have to question brand name APIs, as most large companies, like Google, Microsoft, and IBM, are just creating APIs because it’s another way to make some money.

Don’t get us wrong, it’s great that there are more APIs available but the growth of the market has created a spectrum of quality. Once again in a market niche there are very few standards, quantitative measurements, or unified methods of accessibility. This means that quality APIs that are available from companies like Kairos, who specify in perfecting their APIs, get lost in the noise and developers and business professionals end up wasting time and money reiterating version after version with the wrong APIs for their needs.

RapidAPI solves this problem by bringing all public APIs to one place. Developers can not only connect more easily to these APIs, and manage multiple connections, but they can also rate them, discuss them, and help shine a light on the best APIs.

 

Where Does Kairos Fit into This?

Well, since you asked, our API is on RapidAPI :-)

On top of that, RapidAPI encourages developers to look at other APIs and find ways to mash them together. For example, why not try our emotion analysis API and mash it with Giphy to recall what emotions are being evoked within .gifs that contain faces? With RapidAPI you can do that by searching for Kairos and Giphy.

 

Build a Kairos API Project Using RapidAPI

 

Photo gallery of female beauty models

 

Let’s step through a simple developer friendly example on how to use Kairos API to detect and recognize faces from a gallery. Even if you’re not a developer, you should be able to follow along - There's a screencast from our Engineer, Josue, at the end of this article too.

 

STEP 1

First, you will need login to your Kairos account, or sign-up for a free Personal Kairos API account.

And also you'll need a free RapidAPI account.

We will follow instructions below using Docker running on your machine, which you can download and install from the Docker website - Get Docker here.

 

STEP 2

Next, via the command line (Terminal), create a project directory to place the following source code files. (In this tutorial, we use MacOS as my development platform).

 

mkdir ~/Desktop/KairosAPI
cd ~/Desktop/KairosAPI

 
 

STEP 3

Download the demo PHP script file:

 

curl -O
https://raw.githubusercontent.com/kairosinc/api-examples/master/examples/external/RapidApi.php

 
 

STEP 4

Open the RapidApi.php file to modify the credentials to access the Kairos API and RapidAPI:

 

open RapidApi.php

 
 

STEP 5

The first few lines of the script file should look like the following, and you should modify the “xxxx” values of the constant variables to the API app_id and app_keys you received from both API services:

 

// setup Kairos and RapidApi credentials:
define('KAIROS_APP_ID', 'xxxxxxxxxxxxxxxxx');
define('KAIROS_APP_KEY', 'xxxxxxxxxxxxxxxxx');

define('RAPIDAPI_API', 'KairosAPI');
define('RAPIDAPI_APP_ID', 'kairosapi');
define('RAPIDAPI_APP_KEY', 'xxxxxxxxxxxxxxxxx');

 
 

STEP 6

Using Terminal, download the latest version of PHP Docker image, and create a running container with the project directory:

 

docker run -it --name kairos -v "$PWD":/var/www/app -w /var/www/app php bash

 

Now, inside the new “Kairos” docker container, execute the following:

 

apt-get update -q && apt-get install -yq git zip unzip

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer

composer require rapidapi/rapidapi-connect

 
 

STEP 7

Finally, run the demo PHP script file:

 

php ./RapidApi.php

 

Output should look similar as below:

 

===== Detect face from image url, and extract features:
- Image URL: https://media.kairos.com/kairos-elizabeth.jpg
- Detected as 'female' with 26 years of age.
- Ethnicity matching: 42% Hispanic, 26% Asian, 16% Black, 11% Other, 5% White


===== Enroll Images:
- Enrolled 'elizabeth' into gallery 'model-photography'
- Enrolled 'becky' into gallery 'model-photography'
- Enrolled 'kathy' into gallery 'model-photography'
- Enrolled 'elizabeth-2' into gallery 'model-photography'
- Enrolled 'elizabeth-3' into gallery 'model-photography'


===== Verify Image:
- Successfully verified model 'elizabeth' was found in gallery 'model-photography'

===== Recognize Image In Existing Gallery:
----> 3 models recognized in gallery 'model-photography':
..... Matched 'elizabeth-2' with 100% confidence
..... Matched 'elizabeth' with 74% confidence
..... Matched 'elizabeth-3' with 68% confidence


===== List Galleries:
---- Galleries found:
----> model-photography
----> myGallery


===== Remove Gallery:
- Successfully removed gallery 'model-photography'

 

Demo output explanation

  • The demo script will beginning by detecting a face from an image url, and extract features such as gender, age, and ethnicity.
  • Then the demo script file will create a modeling photography gallery to enroll model images, and verify a specific model has been enrolled into the gallery.
  • Using a given image url, it will recognize models (candidates) which best match any existing models from the enrolled in the gallery.
  • Last, the demo script will display the existing gallery names, and finally remove the modeling photography gallery.

Watch a screencast example on how to run the docker container, install composer and executing the demo here:

 

Build a Kairos API Project Using RapidAPI

We’ve told you what RapidAPI is and we have shown you how to use it with our API so now it’s up to you to build something cool or share it with your developer friends and have them build something cool to share with the world. The real power behind RapidAPI, if anything, is the ease to switch from one API to another without breaking your code.

Either way, we’re loving RapidAPI and what you can do with it and we hope you try it out soon.

EXTRA SPECIAL THANKS TO

Josue Rodriguez, Software Engineer at Kairos, without whose contribution this article would not have been possible.

 
 
 
 

DEVELOPER?

Analyze faces in your products. Try our API.

START FOR FREE

NOT A DEVELOPER?

Transform your business with face recognition.

LEARN MORE