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 yotiBasic 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 Checkconst documentAuthenticityCheck = new RequestedDocumentAuthenticityCheckBuilder().build(); //Liveness check with 3 retriesconst livenessCheck = new RequestedLivenessCheckBuilder() .forStaticLiveness() .withMaxRetries(3) .build(); //Face Match Check with manual check set to fallbackconst faceMatchCheck = new RequestedFaceMatchCheckBuilder() .withManualCheckFallback() .build(); //ID Document Text Extraction Task with manual check set to fallbackconst 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 aboveconst sessionSpec = new SessionSpecificationBuilder() .withClientSessionTokenTtl(600) .withResourcesTtl(604800) .withUserTrackingId('some-user-tracking-id') .withRequestedCheck(documentAuthenticityCheck) .withRequestedCheck(livenessCheck) .withRequestedCheck(faceMatchCheck) .withRequestedTask(textExtractionTask) .withSdkConfig(sdkConfig) .build(); //Create SessionidvClient .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 filterconst requiredDocument = new RequiredIdDocumentBuilder() .withFilter(filter) .build();// Second required document - no filterconst anotherRequiredDocument = new RequiredIdDocumentBuilder() .build();// Requesting a supporting document to aqquire proof of addressconst supportingDocumentObjective = new ProofOfAddressObjectiveBuilder().build();const supportingDocument = new RequiredSupplementaryDocumentBuilder() .withObjective(supportingDocumentObjective) .build();// Document Authenticity Checkconst documentAuthenticityCheck = new RequestedDocumentAuthenticityCheckBuilder().build();// Compare the details on both documents are the same - only if 2 ID documents are requiredconst documentComparisonCheck = new RequestedIdDocumentComparisonCheckBuilder().build();// Liveness check with 3 retriesconst livenessCheck = new RequestedLivenessCheckBuilder() .forStaticLiveness() .withMaxRetries(3) .build();//Face Match Check with manual check set to fallbackconst faceMatchCheck = new RequestedFaceMatchCheckBuilder() .withManualCheckFallback() .build(); //ID Document Text Extraction Task with manual check set to fallbackconst 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 aboveconst 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 sessionidvClient .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?