onfido
Onfido - JavaScript client for onfido The Onfido API is used to submit check requests.
This package is automatically generated by the OpenAPI Generator project:
- API version: 2.0.0
- Package version: 4.3.0
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
Installation
Node.js
ForInstall via npm:
npm install onfido
Alternatively, if you're using Yarn:
yarn add onfido
Frontend JavaScript: warning
You must not use this project in your application's frontend because it uses API tokens. Instead, you can use the Onfido Web SDK for frontend JavaScript.
If you use this project in your frontend, malicious users could discover the tokens in your source code. You should only use this project in your backend code.
You can read more about API token security in the Onfido API reference documentation.
Getting Started
Please follow the installation instruction and execute the following JS code:
const Onfido = ; const defaultClient = OnfidoApiClientinstance; // Configure API key authorization: Tokenconst token_auth = defaultClientauthentications'Token';token_authapiKey = 'token=' + 'YOUR API KEY';token_authapiKeyPrefix = 'Token'; // Limit the at-rest region, if needed (optional, see https://documentation.onfido.com/#regions)// defaultClient.basePath = Onfido.ApiClient.getBasePathFromSettings(1, {region: 'us'}); const api = ; // Setting applicant detailsconst applicant = ;applicantfirst_name = 'John';applicantlast_name = 'Smith';applicantdob = '1980-01-22';applicantcountry = 'GBR'; // You can also use getters and setters for properties using camelCase:// applicant.setFirstName('John');// applicant.setLastName('Smith'); const address = ;addressbuilding_number = '100';addressstreet = 'Main Street';addresstown = 'London';addresspostcode = 'SW4 6EH';addresscountry = 'GBR'; applicantaddresses = address; // Setting check detailsconst check = ;checktype = 'express';const report = ;reportname = 'identity';checkreports = report; // Using promisesapi; // Using async/awaitasync { try const applicantData = await api; const applicantId = applicantDataid; const checkData = await api; console; catcherror console; };
Uploading and Downloading
For uploading files, the file argument should be a Readable Stream. For example, for uploading a document:
const documentImage = fs;api;
There is currently an issue with OpenAPI Generator, the tool used to generate this library, that prevents downloading files from working in Node. As a workaround, you can use the API endpoints for downloading files directly. See the API documentation for more info:
- Documents: https://documentation.onfido.com/#download-document
- Live Photos: https://documentation.onfido.com/#download-live-video
Documentation for API Endpoints
All URIs are relative to https://api.onfido.com/v2
Class | Method | HTTP request | Description |
---|---|---|---|
Onfido.DefaultApi | cancelReport | POST /checks/{check_id}/reports/{report_id}/cancel | This endpoint is for cancelling individual paused reports. |
Onfido.DefaultApi | createApplicant | POST /applicants | Create Applicant |
Onfido.DefaultApi | createCheck | POST /applicants/{applicant_id}/checks | Create a check |
Onfido.DefaultApi | createWebhook | POST /webhooks | Create a webhook |
Onfido.DefaultApi | deleteWebhook | DELETE /webhooks/{webhook_id} | Delete a webhook |
Onfido.DefaultApi | destroyApplicant | DELETE /applicants/{applicant_id} | Delete Applicant |
Onfido.DefaultApi | downloadDocument | GET /applicants/{applicant_id}/documents/{document_id}/download | Download a documents raw data |
Onfido.DefaultApi | downloadLivePhoto | GET /live_photos/{live_photo_id}/download | Download live photo |
Onfido.DefaultApi | downloadLiveVideo | GET /live_videos/{live_video_id}/download | Download live video |
Onfido.DefaultApi | editWebhook | PUT /webhooks/{webhook_id} | Edit a webhook |
Onfido.DefaultApi | findAddresses | GET /addresses/pick | Search for addresses by postcode |
Onfido.DefaultApi | findApplicant | GET /applicants/{applicant_id} | Retrieve Applicant |
Onfido.DefaultApi | findCheck | GET /applicants/{applicant_id}/checks/{check_id} | Retrieve a Check |
Onfido.DefaultApi | findDocument | GET /applicants/{applicant_id}/documents/{document_id} | A single document can be retrieved by calling this endpoint with the document’s unique identifier. |
Onfido.DefaultApi | findLivePhoto | GET /live_photos/{live_photo_id} | Retrieve live photo |
Onfido.DefaultApi | findLiveVideo | GET /live_videos/{live_video_id} | Retrieve live video |
Onfido.DefaultApi | findReport | GET /checks/{check_id}/reports/{report_id} | A single report can be retrieved using this endpoint with the corresponding unique identifier. |
Onfido.DefaultApi | findReportTypeGroup | GET /report_type_groups/{report_type_group_id} | Retrieve single report type group object |
Onfido.DefaultApi | findWebhook | GET /webhooks/{webhook_id} | Retrieve a Webhook |
Onfido.DefaultApi | generateSdkToken | POST /sdk_token | Generate a SDK token |
Onfido.DefaultApi | listApplicants | GET /applicants | List Applicants |
Onfido.DefaultApi | listChecks | GET /applicants/{applicant_id}/checks | Retrieve Checks |
Onfido.DefaultApi | listDocuments | GET /applicants/{applicant_id}/documents | List documents |
Onfido.DefaultApi | listLivePhotos | GET /live_photos | List live photos |
Onfido.DefaultApi | listLiveVideos | GET /live_videos | List live videos |
Onfido.DefaultApi | listReportTypeGroups | GET /report_type_groups | Retrieve all report type groups |
Onfido.DefaultApi | listReports | GET /checks/{check_id}/reports | All the reports belonging to a particular check can be listed from this endpoint. |
Onfido.DefaultApi | listWebhooks | GET /webhooks | List webhooks |
Onfido.DefaultApi | restoreApplicant | POST /applicants/{applicant_id}/restore | Restore Applicant |
Onfido.DefaultApi | resumeCheck | POST /checks/{check_id}/resume | Resume a Check |
Onfido.DefaultApi | resumeReport | POST /checks/{check_id}/reports/{report_id}/resume | This endpoint is for resuming individual paused reports. |
Onfido.DefaultApi | updateApplicant | PUT /applicants/{applicant_id} | Update Applicant |
Onfido.DefaultApi | uploadDocument | POST /applicants/{applicant_id}/documents | Upload a document |
Onfido.DefaultApi | uploadLivePhoto | POST /live_photos | Upload live photo |
Documentation for Models
- Onfido.Address
- Onfido.Applicant
- Onfido.ApplicantsList
- Onfido.Check
- Onfido.CheckCommon
- Onfido.CheckWithReportIds
- Onfido.ChecksList
- Onfido.Document
- Onfido.DocumentsList
- Onfido.Error
- Onfido.GenericAddress
- Onfido.GenericAddressesList
- Onfido.IdNumber
- Onfido.LivePhoto
- Onfido.LivePhotosList
- Onfido.LiveVideo
- Onfido.LiveVideosList
- Onfido.Report
- Onfido.ReportDocument
- Onfido.ReportOption
- Onfido.ReportType
- Onfido.ReportTypeGroup
- Onfido.ReportTypeGroupsList
- Onfido.ReportsList
- Onfido.SdkTokenRequest
- Onfido.SdkTokenResponse
- Onfido.Webhook
- Onfido.WebhooksList
Documentation for Authorization
Token
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header