Web SDK (Javascript)

Andia selfie SDK for WEB (Chrome, Firefox, Internet Explorer 10)

Requirements

A desktop browser with full HTML5 support and access to a webcam.

** Due to the mobile web browsers restrictions, this SDK doesn't work on mobile devices **

  • Google Chrome 53+

  • Microsoft Edge 12+

  • Mozilla Firefox 42+

  • Safari 11+ (Mac)

Example

Integration

The integration of this SDK is very straight forward.

1) Inside any HTML page just import the Javascript library before the </body> tag

<script src="https://api.andia.io/web/andiaSdk.min.js"></script>

2) Include the following HTML fragment, to add a button

<div id="containerAndia"></div>
<button id="andiaBtn" type="button"
class="btnAndia"
customerId="YOUR_CUSTOMER_API_KEY"
user_hash="xxxxx"
face_id=""
action="onboarding" >
<div id="labelBtn">Onboard me</div>
</button>

Parameters

customerID . Your customer API_KEY , mandatory (we provide these credentials) user_hash Optional: Needed in the Onboarding process, only if you have configured a Webhook as a method of callback. This user hash is only to identify the origin of this request.

face_id Mandatory in the Validation process, this face_id is returned in the Onboarding of a specific User. Then when a Selfie validation is required, this is the way to validate a user against her face_id. This parameter is empty when we call an Onboarding a new user.

action Mandatory: "onboarding" or "validate"

onboarding Perform a new user Selfie Onboarding and get the face_id of this new user.
validate Perform a selfie validation, of an existing user (with an existing face_id), previuosly onboarded. Call this method on Password Recovery, validate transactions, or verify that the user is on front of the webcam.

3) Callback

To get the result of the Selfie Validation or the Selfie Onboarding, just implement the javascript function callbackAndia(success, data), just after the import of the javascript library.

<script src="https://api.andia.io/web/andiaSdk.min.js"></script>
<script>
function callbackAndia(success, data){
console.log("## success ##", success);
console.log(data);
}
</script>

Response parameters

success . Boolean, true if the Selfie was made successful

data A JSON object with the following fields.

Selfie OnBoarding JSON Response

{
success: true, //true if the Selfie is a real user
error_code: 0, // 0 == no errors
error: "", // error description in case of error
user_id: "XXXXXXXX" // face_id, store this ID on your DB an associate to
// the user, to perform future selfie validations
}

Selfie Validation JSON Response

{
success: true, //true if the Selfie is a Match agains the given face_id
error_code: 0, // != 0 if there is an error
error: "", // error description if error_code != 0
message: "It is a Match" // description
}

Optional Callback

To receive the JSON responses in the backend as well as in the frontend, you just have to implement an Endpoint with the POST method, which accepts a JSON as a parameter.