Skip to main content

Decoupling Lens

Decoupling Lens from the Veryfi Data Extraction API – Best Practices

If you want to decouple the Lens SDK from the Veryfi Data Extraction API and handle the extraction process independently, follow these best practices:

1. Set dataExtractionEngine to None:

In the Lens SDK configuration settings, set the dataExtractionEngine parameter to None. This disables automatic data extraction after image capture.

2. Enable uploadWithoutProcessingIsOn:

Set uploadWithoutProcessingIsOn to true in your Lens SDK configuration. This ensures that the SDK uploads the .zip package (which contains the image and metadata) to Veryfi’s S3 bucket without triggering an API call for data extraction.

3. Handle the Package Manually:

Once the image is uploaded, the onVeryfiLensSuccess callback will return metadata including the bucket name and package_path. You can use this information to call the Veryfi Data Extraction API from your backend or preferred processing service.

Success response example:

{
"data": {
"bucket": "veryfi-lens-uploads",
"document_type": "receipt",
"external_id": "your-external-id",
"img_original_path": "path/to/original/image.jpg",
"img_stitched_pdf_path": "path/to/stitched.pdf",
"img_thumbnail_path": "path/to/thumbnail.jpg",
"package_path": "path/to/package.zip",
"upload_time_s": 3,
"img_paths": ["path/to/image1.jpg", "path/to/image2.jpg"]
},
"device_id": "ed259234-5610-33b7-ab5b-4b2bc3f2cac2",
"document_type": "receipt",
"package_id": "package-456",
"status": "success"
}

This setup gives you full control over when and how data extraction occurs, allowing for custom workflows or deferred processing.

Here’s an Example of How to Call the Veryfi Data Extraction API

const response = await axios({
method: "POST",
url: "https://api.veryfi.com/api/v8/partner/documents/",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"CLIENT-ID": credentials.clientId,
"AUTHORIZATION": `apikey ${credentials.username}:${credentials.apiKey}`,
},
data: {
bucket: bucket,
package_path: packagePath,
document_type: documentType,
device_data: {meta: {upload_time_s: uploadingTime}},
external_id: externalId,
}
});