Quick start
We suggest you read through the step by step integration guide to understand the integration in detail. Please see below for example code snippets and examples projects.
Before you start
You will need to access your Yoti Hub account with an e-mail & password or using the Yoti mobile app and to have registered your business with Yoti. Click below for more info.
Example code
Below is an example complete request snippet in different languages.
Install the SDK
npm install -S -E yoti
Basic session
This is a basic example showing:
- One document authenticity check
- Text extraction
- Liveness
- Face match.
x
const path = require('path');
const fs = require('fs');
const {
IDVClient,
SessionSpecificationBuilder,
RequestedDocumentAuthenticityCheckBuilder,
RequestedLivenessCheckBuilder,
RequestedTextExtractionTaskBuilder,
RequestedFaceMatchCheckBuilder,
SdkConfigBuilder
} = require('yoti');
const YOTI_CLIENT_SDK_ID = 'YOTI_CLIENT_SDK_ID';
const YOTI_PEM = fs.readFileSync(path.join(__dirname, '/path/to/pem'));
const idvClient = new IDVClient(YOTI_CLIENT_SDK_ID, YOTI_PEM);
//Document Authenticity Check
const documentAuthenticityCheck = new RequestedDocumentAuthenticityCheckBuilder().build();
//Liveness check with 3 retries
const livenessCheck = new RequestedLivenessCheckBuilder()
.forStaticLiveness()
.withMaxRetries(3)
.build();
//Face Match Check with manual check set to fallback
const faceMatchCheck = new RequestedFaceMatchCheckBuilder()
.withManualCheckFallback()
.build();
//ID Document Text Extraction Task with manual check set to fallback
const textExtractionTask = new RequestedTextExtractionTaskBuilder()
.withManualCheckFallback()
.build();
//Configuration for the client SDK (Frontend)
const sdkConfig = new SdkConfigBuilder()
.withPresetIssuingCountry('GBR')
.withSuccessUrl('/success')
.withErrorUrl('/error')
.build();
//Buiding the Session with defined specification from above
const sessionSpec = new SessionSpecificationBuilder()
.withClientSessionTokenTtl(600)
.withResourcesTtl(604800)
.withUserTrackingId('some-user-tracking-id')
.withRequestedCheck(documentAuthenticityCheck)
.withRequestedCheck(livenessCheck)
.withRequestedCheck(faceMatchCheck)
.withRequestedTask(textExtractionTask)
.withSdkConfig(sdkConfig)
.build();
//Create Session
idvClient
.createSession(sessionSpec)
.then((session) => {
const sessionId = session.getSessionId();
const clientSessionToken = session.getClientSessionToken();
const clientSessionTokenTtl = session.getClientSessionTokenTtl();
})
.catch((err) => {
// handle err
});
Advanced session
This is an advanced example showing:
- One document authenticity check
- Text extraction
- Liveness
- Face match
- Supporting document
- Proof of address
- Document filters.
const path = require('path');
const fs = require('fs');
const { } = require('yoti');
const YOTI_CLIENT_SDK_ID = 'YOTI_CLIENT_SDK_ID';
const YOTI_PEM = fs.readFileSync(path.join(__dirname, '/path/to/pem'));
const idvClient = new IDVClient(YOTI_CLIENT_SDK_ID, YOTI_PEM);
const filter = new OrthogonalRestrictionsFilterBuilder()
// Allow from specific countries
.withWhitelistedCountries(['GBR', 'JPN'])
// Allow specific documents
.withWhitelistedDocumentTypes(['PASSPORT'])
.build();
// First required document - with filter
const requiredDocument = new RequiredIdDocumentBuilder()
.withFilter(filter)
.build();
// Second required document - no filter
const anotherRequiredDocument = new RequiredIdDocumentBuilder()
.build();
// Requesting a supporting document to aqquire proof of address
const supportingDocumentObjective = new ProofOfAddressObjectiveBuilder().build();
const supportingDocument = new RequiredSupplementaryDocumentBuilder()
.withObjective(supportingDocumentObjective)
.build();
// Document Authenticity Check
const documentAuthenticityCheck = new RequestedDocumentAuthenticityCheckBuilder().build();
// Compare the details on both documents are the same - only if 2 ID documents are required
const documentComparisonCheck = new RequestedIdDocumentComparisonCheckBuilder().build();
// Liveness check with 3 retries
const livenessCheck = new RequestedLivenessCheckBuilder()
.forStaticLiveness()
.withMaxRetries(3)
.build();
//Face Match Check with manual check set to fallback
const faceMatchCheck = new RequestedFaceMatchCheckBuilder()
.withManualCheckFallback()
.build();
//ID Document Text Extraction Task with manual check set to fallback
const textExtractionTask = new RequestedTextExtractionTaskBuilder()
.withManualCheckFallback()
.build();
//Configuration for the client SDK (Frontend)
const sdkConfig = new SdkConfigBuilder()
.withAllowsCameraAndUpload()
.withPrimaryColour('#2d9fff')
.withSecondaryColour('#FFFFFF')
.withFontColour('#FFFFFF')
.withLocale('en-GB')
.withPresetIssuingCountry('GBR')
.withSuccessUrl('/success')
.withErrorUrl('/error')
.withPrivacyPolicyUrl('/privacy-policy')
.withAllowHandoff(true)
.withIdDocumentTextExtractionGenericRetries(3)
.withIdDocumentTextExtractionReclassificationRetries(3)
.build();
//Notifications config
const notificationConfig = new NotificationConfigBuilder()
.withEndpoint('https://yourdomain.example/idverify/updates')
.withAuthToken('username:password')
.forSessionCompletion()
.build();
//Buiding the Session with defined specification from above
const sessionSpec = new SessionSpecificationBuilder()
.withClientSessionTokenTtl(600)
.withResourcesTtl(604800)
.withUserTrackingId('some-user-tracking-id')
.withRequiredDocument(requiredDocument)
.withRequiredDocument(anotherRequiredDocument)
.withRequiredDocument(supportingDocument)
.withRequestedCheck(documentAuthenticityCheck)
.withRequestedCheck(documentComparisonCheck)
.withRequestedCheck(livenessCheck)
.withRequestedCheck(faceMatchCheck)
.withRequestedTask(textExtractionTask)
.withSdkConfig(sdkConfig)
.withNotifications(notificationConfig)
.build();
//Create session
idvClient
.createSession(sessionSpec)
.then((session) => { })
.catch((err) => { });
Web examples
If we don't support your language please get in touch with us.
Was this page helpful?