API reference guide
1. Introduction
This document includes the API description for the libraries provided in the product FacePhi SelphID SDK.
2. SelphID API Description (Front End)
SelphID SDK is a set of server libraries that uses the information generated by the Facephi Widgets for native or web applications. As described in the following sections, components called Widgets are provided for face capture (Selphi) and identity document capture (SelphID), which can be integrated into the front end of any application.
2.1. Selphi Widget
Using the Selphi, which incorporates the user's facial and liveness detection and extraction mechanism, the following information can be obtained through the properties listed below:
Imageproperty: Represents the user's image with the most frontal facial pose detected.TemplateRawproperty: Represents the user's tokenized biometric template with the most frontal facial pose detected. This template is used to perform biometric authentication with SelphID SDK.
Note
Additionally, a tokenized functionality is provided, generateTemplateRaw (see API), which allows an image or data buffer to be converted into a tokenized data buffer in the form of
templateRaw. ThistemplateRawcan be used in various SelphID SDK functionalities.
2.2. SelphID Widget
Using the SelphID, which incorporates the automatic document detection and capture mechanism, the following information can be obtained through the properties listed below:
TokenOCRproperty: Represents a token (timestamp + AES256 encryption) containing the data detected in the document through the OCR performed.TokenFrontDocumentproperty: Represents the tokenized image (timestamp + AES256 encryption) of the front of the document, cropped to the document edges.TokenBackDocumentproperty: Represents the tokenized image (timestamp + AES256 encryption) of the back of the document, cropped to the document edges.TokenFaceImageproperty: Represents the tokenized image (timestamp + AES256 encryption) of the user's photograph on the document. This token is used to perform biometric authentication with the SDK.TokenRawFrontDocumentproperty: Represents the tokenized image (timestamp + AES256 encryption) of the front of the document, not cropped to the document edges—that is, as captured by the camera.TokenRawBackDocumentproperty: Represents the tokenized image (timestamp + AES256 encryption) of the back of the document, not cropped to the document edges—that is, as captured by the camera.
3. SelphID API Description (Back End)
The API for the libraries provided in SelphID is described below, detailing the methods that the integrator can use to incorporate facial recognition, information extraction from identity documents, and document validation features.
3.1. Library Initialization
SelphIDVerifier represents the main class of the libraries, which contains all the methods available for each of the functionalities.
The libraries can be initialized in three different ways, depending on the configured environment variables:
3.1.1. Initialization using the method loadWithConfigPath()
Prerequisites
Configure the environment variables and the config.cfg file (SDK configuration for On-premise installation):
FACEPHI_SELPHID_INSTALL_PATH
FACEPHI_SELPHID_INSTALL_BIN
LD_LIBRARY_PATH
PATH
3.1.2. Initialization using the method load()
Prerequisites
Configure the environment variables and the config.cfg file (SDK configuration for On-premise installation):
FACEPHI_SELPHID_INSTALL_PATH
FACEPHI_SELPHID_INSTALL_BIN
LD_LIBRARY_PATH
PATHThere is no need to specify the path to the configuration file, as it will be searched for automatically at the following path:
FACEPHI_SELPHID_INSTALL_PATH/config/selphid.cfg
3.1.3. Initialization using the method loadFromEnvVars()
Prerequisites
Configure the environment variables (SDK configuration for On-premise installation):
FACEPHI_SELPHID_INSTALL_PATH
FACEPHI_SELPHID_INSTALL_BIN
LD_LIBRARY_PATH
PATH
FACEPHI_SELPHID_DEBUGPATH_KEY
FACEPHI_SELPHID_USAGEPATH_KEY
FACEPHI_SELPHID_FACIALLIVENESS_PATH_KEY
FACEPHI_SELPHID_FACIAL_LICPATH_KEYInstead of configuring the config.cfg file, these variables are set directly as environment variables.
Important
The libraries should be initialized using the method
load(),loadWithConfigPath()orloadFromEnvVars()only once during your application's lifecycle.Once all processes involving the use of these libraries have finished, it is important to release the resources associated with them; do not forget to unload the library before closing the application.
The libraries should be finalized using the method
unload()only once during your application's lifecycle. Once the method has been calledunload(), it is no longer possible to perform aload().If any condition occurs that prevents the libraries from loading correctly, a
SelphIDExceptionwill be thrown. For information about the exception types, see the corresponding section 3.10. SelphIDException description in the provided API.
3.2. Facial extraction methods
To extract a user's facial data, the integrator can use different methods in the SelphIDVerifierclass. The integrator should use one method or another depending on the data generated on the client. The possible scenarios are described below.
Note
These methods always return a
SelphIDFacialExtractionResultobject, described in 3.9.1. SelphIDFacialExtractionResult.
3.2.1. Facial extraction using an image
Use the following method:
The steps required to perform facial extraction using an image are as follows (example method):
Prerequisites
Obtain the image (a base64 string) through the Image property using the Selphi Widget.
Send the base64 string of the image to the server.
3.2.2. Facial extraction using a template
Use the following method:
The steps required to perform facial extraction using a biometric template are as follows (example method):
Prerequisites
Obtain the biometric template (a base64 string) through the TemplateRaw property using the Selphi Widget.
Send the base64 string of the biometric template to the server.
3.3. Facial authentication methods
To perform facial authentication for a user, the integrator can use different methods in the SelphIDVerifier. The integrator must use one method or the other depending on the data generated on the client. Each of the possible scenarios is described in the following subsections.
Note
The result of these methods will always be an object
SelphIDFacialAuthenticationResult, explained in 3.9.2. SelphIDFacialAuthenticationResult.
3.3.1. Facial authentication using images
The steps required to perform facial authentication using two images are as follows (example method):
Prerequisites
Obtain the first image (base64 string) through the Image property using the Selphi widget.
Obtain the second image (base64 string) through the Image property using the Selphi widget.
Send both base64 strings to the server.
3.3.2. Facial authentication using biometric templates
Use the following method:
The steps required to perform facial authentication using two biometric templates are as follows (example method):
Prerequisites
Obtain the first biometric template (base64 string) through the TemplateRaw property using the Selphi widget.
Obtain the second biometric template (base64 string) through the TemplateRaw property using the Selphi widget.
Send both base64 strings to the server.
3.3.3. Facial authentication using an image and a biometric template
Use the following method:
The steps required to perform facial authentication using an image and a biometric template are as follows (example method):
Prerequisites
Obtain the image (a base64 string) through the Image property using the Selphi Widget.
Obtain the biometric template (a base64 string) through the TemplateRaw property using the Selphi Widget.
Send both base64 strings to the server.
3.3.4. Facial authentication using the document photograph and an image
Use the following method:
The steps required to perform facial authentication using the document photograph and an image are as follows (example method):
Prerequisites
Obtain the document photograph token (base64 string) through the TokenFaceImage property using the SelphID widget.
Obtain the image (a base64 string) through the Image property using the Selphi Widget.
Send both base64 strings to the server.
3.3.5. Facial authentication using the document photo and a biometric template
Use the following method:
The steps required to perform facial authentication using the document photo and the user's biometric template are as follows (example method):
Prerequisites
Obtain the document photograph token (base64 string) through the TokenFaceImage property using the SelphID widget.
Obtain the biometric template (a base64 string) through the TemplateRaw property using the Selphi Widget.
Send both base64 strings to the server.
3.4. Document data extraction method
To obtain the document data required for digital onboarding processes, the integrator can use a method in the SelphIDVerifier.
Note
class. This method returns an object
SelphIDDocumentResultthat contains all the data detected in the document. For more information, see 3.9.3. SelphIDDocumentResult.
3.4.1. Retrieving data detected in a document
Use the following method:
The steps required to retrieve data from a document are as follows (example method):
Prerequisites
Get the value of the
TokenOCRproperty (a Base64 string) using the SelphID Widget.Send the Base64 string to the server.
3.5. Liveness evaluation methods
To evaluate the user's liveness on the server—a necessary feature in the digital onboarding process to prevent photo or video fraud—the integrator can use a method in the SelphIDVerifier.
Note
class. These methods always return an object of type
SelphIDFacialLivenessResult, described in 3.9.4. SelphIDFacialAuthenticationResult.
3.5.1. Liveness evaluation from an image
The steps required to perform facial authentication using two images are as follows (example method):
Prerequisites
Get an image of the user (Base64 string) using the Selphi Widget.
Send the base64 string of the image to the server.
3.5.2. Liveness evaluation from a tokenized image
Starting with Version
6.21.0, the tokenized image includes a defense mechanism against injection attacks. If an invalid token is detected,NoneBecauseTokenDataErrororNoneBecauseTokenSecuritywill be returned as the diagnostic.
The steps required to perform facial authentication using two images are as follows (example method):
Prerequisites
Get an image of the user (Base64 string) using the Selphi Widget.
Send the base64 string of the image to the server.
3.6. 1:N identification methods
To perform 1:N searches that identify a given biometric pattern against a database and return a set of candidates with a higher similarity score, the integrator can use different methods in the SelphIDIdentifier.
3.6.1. Building the search gallery
Before performing identification operations, you must create a gallery and register the biometric patterns to be searched in it. You can add templates to the gallery using the following methods:
Both methods specify the ID of the gallery to which the template should be added, as well as a logical ID related to the application's business logic, so that candidates returned from a gallery search can be linked to it.
Note
To enroll a biometric template in a gallery, you must generate the equivalent facial pattern, or FacialTemplate, using one of the following methods of the
SelphIDVerifier:
ExtractFacialWithRawTemplate
ExtractFacialWithImageBufferSee the section 3.2.1. Facial extraction using an image.
3.6.2. Identifying a template against a search gallery
The search process is performed using either of the following methods of the SelphIDIdentifier:
Specify the gallery ID and an object SelphIDIdentifierOptions with the following search options:
MaxIdentificationCandidates, to specify the maximum number of candidates to return, sorted from highest to lowest similarity percentage.MinIdentificationSimilarity, to specify the minimum similarity threshold for including a candidate in the result set.
Note
By default,
MaxIdentificationCandidatesis20andMinIdentificationSimilarityis0f.
Below, we’ll look at an example using both methods:
Note
To learn more about
SelphIDIdentifierResult, see section 3.9.5. SelphIDIdentifierResult.
3.6.3. Removing a template from the gallery
The removal process blocks a biometric template in a specific gallery so that it is not considered during identification. If we use the environment variable FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=noerase, this removal does not reduce the gallery size or change the indexing of the associated biometric templates. Conversely, omitting this variable or using FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=erase reduces the gallery size after removal, changing the indexing of the templates.
The removal process is carried out using the following method of the SelphIDIdentifier:
3.6.4. View and remove obsolete templates
Starting with Version 6.17.0, each biometric pattern stores the timestamp (system clock) at which it was indexed in the gallery. This makes it possible to view and remove “expired” templates according to specific criteria.
In both cases, the template IDs whose timestamps are earlier than the specified interval (in seconds) will be listed. In the case of removeObsoleteGalleryTemplateIDs(), the operation will be atomic and will remove all obsolete templates in a single operation. If you have configured FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=erase, the gallery size will be reduced and the remaining templates will be reindexed.
3.6.5. Retrieving information about a gallery
The purpose of the gallery information retrieval process is to serve as a preliminary step for performing other queries on the gallery.
The process is performed using the following class: SelphIDIdentifier:
A gallery identifier must be used to retrieve information about a specific gallery. Next, we’ll look at the SelphIDFacialGalleryInfo:
3.6.6. Query the indices that match a templateID specific
The process of querying all the indexes in a gallery that match an exact value of templateID must be performed using the following method from SelphIDFacialGalleryInfo which we saw in the previous section:
Important
Starting with SelphID
6.15.0, items with duplicate templateIDs are not allowed.
A templateID that matches the templateID being searched for in the gallery.
To do this, you need an instance of SelphIDFacialGalleryInfo with valid data:
3.7. Orchestrator
The orchestrator lets you perform facial authentication and the person's liveness check in a single call. You can choose to run the check with an image and a template, or with two templates.
Important
The liveness check will only be performed after successful authentication.
Note
For more information about
SelphIDVerifierResult, see section 3.9.6. SelphIDVerifierResult.
3.8. API Tracking
Starting with version 4.1.0, SelphID-SDK includes event tracking functionality that lets you monitor and view API activity through a web interface. The SelphID license includes all the data required to access the platform (in the single-tenant version).
All previous methods from other API versions remain available. Some duplicate methods have been added; these now take a new parameter containing tokenized data with the essential information for communicating with the tracking server. This parameter is called extraData.
3.8.1. Multi-tenant Version
Starting with version 4.3.0, SelphID-SDK supports two operating modes for event logging through API Tracking:
Single-tenant: The API Tracking service connection data is encrypted in the SelphID-SDK license and is used for all calls to the service.
Multi-tenant: The connection data is received with each call from the mobile application. This allows the SDK to log events to different servers depending on the client making the call.
Important
To enable multi-tenant mode, tracking data must not be included in the SelphID-SDK license. Otherwise, single-tenant mode will be activated when the backend starts.
Starting with version 5.0.0, you can switch between Single-tenant and Multi-tenant modes at runtime using these SelphIDVerifier:
3.8.2. Logging
The following method decrypts the tokenized data in rawDocumentBuffer, such as OCR data, document images, etc. The parameter extraData must contain the data required by the tracking service.
The following methods take an encrypted image rawTemplateBufferTarget or an unencrypted image imageBufferTarget, to compare it with the image extracted from the document rawDocumentBufferQuery. In both cases, the data required by the tracking service must be provided in the parameter extraData.
3.8.3. SelphIDVerifierOptions
The following methods, added to the class SelphIDVerifierOptions, allow information entered by the client to be represented on the tracking servers for the registration use case.
The input parameter of the setOptionalDataClientInformation method must be well-formed JSON that accepts the following keys:
Note
Any other keys will be ignored. Support for additional keys will be added in the future.
Starting with version 6.17.0, the futureTimeAllowedproperty was added. This allows you to set a time interval (in seconds) during which templates and tokenized images with a future date will be accepted, returning true from the getValidTimeStamp()method. This is intended to mitigate time zone differences between devices. This value can be configured globally using the environment variable FACEPHI_SELPHID_FUTURE_TIME_ALLOWED=3600.
Starting with version 6.18.0, we can specify which Liveness pipelines to run for each operation using setLivenessDepth(). In the case of None (the default value), the global configuration set by FACEPHI_SELPHID_FACIALLIVENESS_DEPTH.
3.8.4. Authentication
The following methods are available for performing authentication. The parameters rawTemplateBuffer receive the encrypted image, and the parameter imagebufferQuery receives the unencrypted image. In both cases, the data required by the tracking service must be sent in the extraData.
3.8.5. Passive liveness
The following methods are available for performing the passive liveness check. The parameter tokenBuffer receives the encrypted image, and imageBuffer the unencrypted image. In both cases, the data required by the tracking service must be sent in the extraData.
3.8.6. Custom events
Starting with version 4.5.0, SelphID supports sending custom events to the Tracking API that are not linked to any internal SDK operation. All custom event operations return a status code and a message in a SelphIDApiTrackingResult.
The following method sends the Facial Authenticationevent to the Tracking API using the parameters authStatus and similarity. We can also register the image(s) involved in the authentication with the Tracking API service. Both images are optional; null or empty buffers are accepted.
Possible values for TrackingFamily:
The following method sends the Livenessevent to the Tracking API using the parameters diagnostic and similarity. We can also register the image involved in the liveness process with the Tracking API service. This is optional; null or empty buffers are accepted.
The following method sends the Voice Authenticationevent to the Tracking API using the parameter probability. We can also register the audio tracks involved in the voice authentication process with the API Tracking service. Both buffers are optional and accept null or empty values.
The following method sends a custom OCR event to the API Tracking server.
ocrDataJson is a well-formed JSON key-value dictionary. It accepts any key name with any string value:
The following method sends a custom SECURITY_INFO_DATA event to the API Tracking server:
securityDataJson contains the security data in JSON format:
succeed is a boolean value indicating whether the security data was retrieved successfully, and source is the name of the service or source of the security data.
For all custom event operations, we can modify the encrypted field eventSource within the extraData.
For custom events, you can close the operation using the following method:
This method registers the following events with the API Tracking service: Operation result (Operation result) and Step change finish (Step change finish), which close the operation.
Important
The meaning of these attributes, including the enums mentioned, is determined by the user.
Possible values of OperationResultStatus:
Possible values of OperationResultReason:
3.8.7. Proxy server
Starting with SelphID-SDK version 4.5.5, it is possible to send requests to the Tracking API through a proxy server. To configure the proxy parameters, use the following method:
To disable the proxy, an empty string must be passed as the proxyHost.
3.9. API result description
The following properties in the result classes allow you to evaluate the results of each of the methods mentioned above.
Starting with version 6.18.0, in addition to checking the validity of a token using getValidTimeStamp(), we can now obtain the timestamp embedded in the token itself using getTokenTimeStamp(). This affects:
SelphIDFacialExtractionResult.SelphIDFacialAuthenticationResult.SelphIDDocumentResult.SelphIDFacialLivenessResult.
3.9.1. SelphIDFacialExtractionResult
Provides various properties for evaluating the facial extraction result:
Possible values for FacialPose:
Possible values of FacialQuality:
Possible values of Glasses:
Possible values of Gender:
3.9.2. SelphIDFacialAuthenticationResult
It provides various properties for evaluating the biometric authentication result:
Important
To evaluate the result, use the
FacialAuthenticationStatusproperty; thesimilarityvalue is used for statistical purposes only.
Possible values of FacialAuthenticationStatus:
3.9.3. SelphIDDocumentResult
It provides various methods for retrieving the images used in the process and the data read from the document. The methods are as follows:
3.9.4. SelphIDFacialLivenessResult
Provides the FacialLivenessDiagnostic property to evaluate the passive liveness check diagnostic result.
Possible values of FacialLivenessDiagnostic:
Starting with version 6.18.0, the structure SelphIDNoLiveDetails is included, with additional information about the NoLivecase. In the Livecase, we can also query the pipeline scores.
3.9.5. SelphIDIdentifierResult
Provides different methods for obtaining comparison information for each of the candidates returned as the result of a 1:N search. They are as follows:
Possible values of FacialAuthenticationStatus:
Possible values of FacialAuthenticationDetail:
3.9.6. SelphIDVerifierResult
Provides different methods for obtaining information from the orchestrator. They are as follows:
Note
For more information:
3.9.7. SelphIDApiTrackingResult
Provides different methods for obtaining information about the API Tracking operation. They are as follows:
3.10. Description of SelphIDException
If an error occurs within SelphID-SDK, the SelphIDException exception will be thrown.
Possible values of SelphIDExceptionType:
Last updated