regulaforensics / DocumentReader-web-js-client

Regula Document Reader web API js client for the browser and node.js based on axios
https://regulaforensics.com
8 stars 6 forks source link
barcode-reader document-reader document-recognition idcard mrz mrz-codes ocr passport regula regulaforensics

Regula Document Reader js client for the browser and node.js based on axios

npm version npm type definitions documentation OpenAPI live

Documents recognition as easy as reading two bytes.

If you have any problems with or questions about this client, please contact us through a GitHub issue. You are invited to contribute new features, fixes, or updates, large or small. We are always thrilled to receive pull requests, and do our best to process them as fast as we can. See dev guide

Install package

npm install @regulaforensics/document-reader-webclient

Basic Example

Performing request:

import { DocumentReaderApi, Scenario, TextFieldType, GraphicFieldType } from '@regulaforensics/document-reader-webclient';
const { DOCUMENT_NUMBER, SURNAME_AND_GIVEN_NAMES, DATE_OF_BIRTH } = TextFieldType;
const { PORTRAIT, SIGNATURE } = GraphicFieldType;

const imageAsBase64String = getDocImageAsBase64String();
const api = new DocumentReaderApi({ basePath: 'http://localhost:8080' });
const result = await api.process({ images: [documentImage], processParam: { scenario: Scenario.FULL_PROCESS} });

Parsing results:

// text fields
const docNumber = result.text?.getField(DOCUMENT_NUMBER);
const fullName = result.text?.getField(SURNAME_AND_GIVEN_NAMES);
const dateOfBirth = result.text?.getField(DATE_OF_BIRTH);

// graphics fields
const portraitAsBase64 = result.images?.getField(PORTRAIT);
const signatureAsBase64 = result.images?.getField(SIGNATURE);

Compatibility

Language level

Module system

Definitions