SDKs overview

Onfido offers a suite of Software Development Kits (SDKs) designed to facilitate the integration of its identity verification services into various applications. These SDKs handle the front-end user experience for capturing identity documents and biometric data, such as facial biometrics, which are then processed by Onfido's API. The primary goal of these SDKs is to reduce integration complexity, ensure a consistent user experience, and optimize data capture for verification accuracy. Onfido's developer documentation provides comprehensive guides for each SDK, detailing installation, configuration, and usage patterns to support diverse implementation needs.

The SDKs abstract away the complexities of device camera access, image optimization, and secure data transmission, allowing developers to focus on their core application logic. By providing pre-built UI components and workflows, Onfido's SDKs help maintain brand consistency while adhering to identity verification best practices. The availability of SDKs for web and native mobile platforms ensures broad compatibility across different application environments.

Official SDKs by language

Onfido provides official SDKs for common application development environments, ensuring direct support and continuous updates from the vendor. These SDKs are maintained to align with the latest API versions and security standards. The primary official SDKs include those for iOS, Android, and Web applications, catering to native mobile and browser-based interfaces respectively. Each SDK is designed to streamline the specific challenges of its platform, from managing camera permissions on mobile devices to handling cross-browser compatibility on the web.

In addition to the front-end SDKs, Onfido also provides server-side client libraries or code examples in several popular programming languages, including Python, Ruby, and Node.js, to interact with the Onfido API directly. These libraries facilitate server-side operations such as creating applicants, initiating checks, and retrieving verification results, complementing the front-end data capture performed by the SDKs.

Onfido Official SDKs and Server-Side Libraries
Platform/Language Package/Module Install Command Example Maturity
iOS (Swift/Objective-C) Onfido iOS SDK pod 'Onfido' (CocoaPods) Stable
Android (Kotlin/Java) Onfido Android SDK implementation 'com.onfido.android:onfido-sdk:latest_version' (Gradle) Stable
Web (JavaScript) Onfido Web SDK npm install @onfido/onfido-sdk-ui (npm) Stable
Python (Server-side) onfido-python pip install onfido Stable
Ruby (Server-side) onfido-ruby gem install onfido Stable
Node.js (Server-side) onfido-node npm install onfido Stable

Installation

Installing Onfido's SDKs typically involves using standard package managers for each respective platform, ensuring dependency management and version control. The Onfido developer documentation provides detailed, platform-specific installation instructions for each SDK, addressing common prerequisites and configuration steps.

iOS SDK Installation

For iOS projects, the Onfido SDK is commonly integrated using CocoaPods or Swift Package Manager. After adding the SDK, specific permissions for camera access must be configured in the application's Info.plist file.

# Using CocoaPods
pod 'Onfido', '~> 22.0'

# After adding, run:
pod install

Android SDK Installation

Android applications integrate the Onfido SDK via Gradle dependencies. Developers need to add the SDK to their module's build.gradle file and ensure the necessary camera and internet permissions are declared in the AndroidManifest.xml.

// In your module's build.gradle file
dependencies {
    implementation 'com.onfido.android:onfido-sdk:latest_version'
}

Web SDK Installation

The Onfido Web SDK can be installed using npm or by including it directly via a Content Delivery Network (CDN). The npm package is the recommended approach for modern web projects, allowing for easier bundling and version management.

npm install @onfido/onfido-sdk-ui # or yarn add @onfido/onfido-sdk-ui

Server-Side Client Library Installation (Node.js Example)

For server-side interactions, such as creating applicants or generating SDK tokens, client libraries are available. The Node.js library, for instance, is installed via npm.

npm install onfido # or yarn add onfido

Quickstart example

This quickstart example demonstrates a basic integration of the Onfido Web SDK and a server-side Node.js script to generate the required SDK token. The process involves two main steps: a server-side component to interact with the Onfido API to create an applicant and generate an SDK token, and a client-side (web) component to launch the Onfido flow using this token.

Server-side (Node.js) - Generate SDK Token

First, set up a server endpoint that calls the Onfido API to create an applicant and then generates an SDK token. This token is crucial for authenticating the client-side SDK session. An applicant defines the individual being verified.

// server.js (Node.js example)
const Onfido = require('onfido');
const express = require('express');
const app = express();
const port = 3000;

// Initialize Onfido API client with your API key
const onfido = new Onfido({
  apiToken: 'YOUR_API_TOKEN' // Replace with your actual Onfido API token
});

app.get('/generate-sdk-token', async (req, res) => {
  try {
    // 1. Create an applicant
    const applicant = await onfido.applicant.create({
      firstName: 'Jane',
      lastName: 'Doe'
    });
    console.log('Applicant created:', applicant.id);

    // 2. Generate an SDK token for the applicant
    const sdkToken = await onfido.sdkToken.generate({
      applicantId: applicant.id,
      referrer: 'http://localhost:3000/*'
    });
    console.log('SDK Token generated:', sdkToken);

    res.json({ sdkToken: sdkToken });
  } catch (error) {
    console.error('Error generating SDK token:', error);
    res.status(500).send('Error generating SDK token');
  }
});

app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});

Client-side (Web) - Launch Onfido Web SDK

On the client side, retrieve the SDK token from your server and initialize the Onfido Web SDK. The SDK will then guide the user through the identity verification process.

<!-- index.html (Client-side example) -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Onfido Quickstart</title>
    <script src="https://assets.onfido.com/web-sdk-releases/latest/@onfido/web-sdk-ui/dist/onfido.min.js"></script>
</head>
<body>
    <h1>Onfido Identity Verification</h1>
    <button id="startOnfido">Start Verification</button>
    <div id="onfido-mount"></div>

    <script>
        const startButton = document.getElementById('startOnfido');
        const onfidoMount = document.getElementById('onfido-mount');

        startButton.addEventListener('click', async () => {
            // 1. Fetch SDK token from your server
            const response = await fetch('http://localhost:3000/generate-sdk-token');
            const data = await response.json();
            const sdkToken = data.sdkToken;

            if (sdkToken) {
                // 2. Initialize and launch Onfido Web SDK
                Onfido.init({
                    token: sdkToken,
                    containerId: 'onfido-mount',
                    onComplete: function(data) {
                        console.log('Onfido flow completed:', data);
                        alert('Verification flow completed! Check server for results.');
                    },
                    onError: function(error) {
                        console.error('Onfido flow error:', error);
                        alert('Verification flow encountered an error.');
                    }
                });
            } else {
                console.error('Failed to get SDK token.');
            }
        });
    </script>
</body>
</html>

To run this example, save the Node.js code as server.js and the HTML code as index.html in the same directory. Install Node.js dependencies (npm install express onfido) and then run node server.js. Open index.html in your browser and click the "Start Verification" button. This setup demonstrates a basic workflow, and for production environments, securing API keys and handling callbacks for verification results are critical next steps, as detailed in the Onfido Web SDK guide and OAuth 2.0 security best practices for token management.

Community libraries

While Onfido provides official SDKs and client libraries for key platforms and languages, the open-source community may develop and maintain additional client libraries or integrations for other languages or frameworks. These community-contributed libraries can extend Onfido's reach into less common development environments or offer alternative approaches to integration. However, it's important to note that community libraries are not officially supported or maintained by Onfido. Developers choosing to use them should verify their security, reliability, and currency with the latest Onfido API specifications.

Typically, community libraries are listed on package managers specific to their programming language (e.g., PyPI for Python, RubyGems for Ruby, npm for JavaScript) or hosted on platforms like GitHub. Developers are encouraged to check the official Onfido developer documentation for recommended integration paths before opting for community-maintained solutions, ensuring comprehensive support and adherence to security standards.