Getting Started
In this guide we will show you how to integrate your web application with the Experience Platform using the Verify JavaScript SDK.
After completing this guide, you will know
- The systems requirements for Integrating with ExperienceSDK,
- How to include the ExperienceSDK in your application
ExperienceSDK - Identity system requirements
Supported Browsers
The following browsers are supported on desktop platforms:
- Chrome (54 or newer)
- Edge (15 or newer)
- Opera (41 or newer)
- Safari (11 or newer)
Recommended Hardware Requirements
- CPU: 2GHz
- RAM: 8GB
Adding the ExperienceSDK - Verify to your web app
The latest version of the ExperienceSDK - Verify is published on Realeyes' CDN (powered by AWS). To include it in your app, just reference the library, eg.:
<script src="https://codesdwncdn.realeyesit.com/experience-sdk/identity/release/latest/reIdentitySdk.min.js"></script>
You also need your ApiKey from Developers Portal to be able to get tokens from Verify Api.
Versioning
The SDK uses semantic versioning, eg.: 1.5.10 Releases can be found, by replacing the version part of the library's link:
https://codesdwncdn.realeyesit.com/experience-sdk/identity/release/{SEMANTIC_VERSION}/reIdentitySdk.min.js
The latest version under a main version can be found under 'MAIN_VERSION' version (e.g. 1.5.10 -> 1): Under a main version we publish versions, which are always backwards compatible.
https://codesdwncdn.realeyesit.com/experience-sdk/identity/release/{MAIN_VERSION}/reIdentitySdk.min.js
Latest versions are always under 'latest' version:
https://codesdwncdn.realeyesit.com/experience-sdk/identity/release/latest/reIdentitySdk.min.js
Working with the ExperienceSDK - Verify
Client-side
Adding the SDK to a web app will automatically instantiate itself under window.Realeyesit.identitySdk
.
In order to start you the SDK you need to call the init method with the following parameters: region and getToken callback function.
async function getToken() {
const response = await fetch("YOUR_API_ENDPOINT");
return await response.text();
}
window.Realeyesit.identitySdk.init("YOUR_REGION", getToken);
const result = window.Realeyesit.identitySdk.verifyDuplicate("YOUR_COLLECTION_NAME", false);
Important
- Api endpoint is implemented on the host side and must call Experience Platform's Verify API's get-token endpoint to get a valid token.
- Region should be set to the preferred region. Currently supported regions are: "eu", "us".
- Collection name should be set. This is text you can use to differentiate collections that you define.
- If the second parameter of verifyDuplicate method is set to true then the result will contain demographical information about the user (age range, gender).
For more information, please visit our JS SDK reference and our Verify API documentation.
By default the configuration seen above is enough to start working with the SDK.
Important
It will ask for camera permission from the user.
Server-side
The Verify SDK interfaces with a secure server-side Verify API that requires tokens.
Here is an example of how to request a token from the Verify API:
import express from 'express';
var app = express();
import fetch from 'node-fetch';
var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
});
app.get('/getToken', function (req, res) {
var result = await fetch('IDENTITY_API_URL', {
headers: {"X-API-Key": "YOUR_API_KEY"}
});
var token = await result.text();
res.end(token);
});
Important
- To request tokens use the Verify API's get-token URL. For more information, please visit our Verify API documentation.
- The API key can be found on Experience Platform's Developer Portal.
Additional configuration
Regions
The currently supported regions are: "eu", "us". We suggest to use the region which is closest to your users.
Callbacks
verifyDuplicate method has 2 optional callbacks:
- onCameraAccessGrantedCallback
- onErrorCallback
These callbacks can be used by the host application to handle errors and notify the user.
For more information, please visit our JS SDK reference
Retry in case of no face is detected
Besides the callback functions, the SDK also has a retry mechanism. If the SDK cannot detect a face, it will automatically retry with a new image.
The default value is 5 for the retry count. The number of retries can be set by the host application when initializing the SDK:
window.Realeyesit.identitySdk.init("YOUR_REGION", getToken, null /* onCameraAccessGrantedCallback */, null /* onErrorCallback */, 10 /* retry count */);
Examples
We know that the easiest way to understand an SDK is through examples. Here you can find some.