New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@creativecodelabs/ocr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@creativecodelabs/ocr

OCR module for document scanning - receipts, invoices, and expense documents using Mindee

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@ccl/ocr

OCR module for document scanning - receipts, invoices, and expense documents using Mindee.

Installation

npm install @ccl/ocr

Setup

Initialize the OCR client with your Mindee API key:

import { initOcrClient } from '@ccl/ocr';

initOcrClient({
  apiKey: process.env.MINDEE_API_KEY,
  // Optional: custom model IDs
  receiptModelId: 'your-custom-receipt-model',
  invoiceModelId: 'your-custom-invoice-model',
});

Usage

Scanning Receipts

import { scanReceiptFromUrl, scanReceiptFromBase64, isReceiptValid } from '@ccl/ocr';

// From URL
const result = await scanReceiptFromUrl('https://example.com/receipt.jpg');

// From base64
const result = await scanReceiptFromBase64(base64String, 'receipt.jpg');

// Check validity
if (isReceiptValid(result)) {
  console.log('Merchant:', result.merchantName);
  console.log('Total:', result.totalAmount, result.currency);
  console.log('Date:', result.transactionDate);
}

Scanning Invoices

import { scanInvoiceFromUrl, scanInvoiceFromBase64, isInvoiceValid } from '@ccl/ocr';

// From URL
const result = await scanInvoiceFromUrl('https://example.com/invoice.pdf');

// From base64
const result = await scanInvoiceFromBase64(base64String, 'invoice.pdf');

// Check validity
if (isInvoiceValid(result)) {
  console.log('Vendor:', result.vendorName);
  console.log('Invoice #:', result.invoiceNumber);
  console.log('Total:', result.totalAmount);
  console.log('Due Date:', result.dueDate);
  console.log('Line Items:', result.lineItems);
}

API Reference

Receipt Fields

FieldTypeDescription
merchantNamestring | nullStore/merchant name
merchantAddressstring | nullMerchant address
transactionDatestring | nullDate (ISO format)
totalAmountstring | nullTotal amount
taxAmountstring | nullTax/VAT amount
currencystring | nullCurrency code (USD, EUR, ZAR)
paymentMethodstring | nullPayment method if detected
lineItemsReceiptLineItem[]Individual items
confidenceobjectConfidence scores (0-1)

Invoice Fields

FieldTypeDescription
vendorNamestring | nullVendor/supplier name
vendorAddressstring | nullVendor address
customerNamestring | nullCustomer/bill-to name
customerAddressstring | nullCustomer address
invoiceNumberstring | nullInvoice number
invoiceDatestring | nullInvoice date
dueDatestring | nullPayment due date
totalAmountstring | nullTotal amount
subtotalstring | nullSubtotal before tax
taxAmountstring | nullTax amount
currencystring | nullCurrency code
poNumberstring | nullPurchase order number
lineItemsInvoiceLineItem[]Line items
confidenceobjectConfidence scores (0-1)

Error Handling

import { OcrError } from '@ccl/ocr';

try {
  const result = await scanReceiptFromUrl(url);
} catch (error) {
  if (error instanceof OcrError) {
    switch (error.code) {
      case 'NOT_CONFIGURED':
        // Client not initialized
        break;
      case 'AUTH_ERROR':
        // Invalid API key
        break;
      case 'RATE_LIMIT':
        // Rate limit exceeded
        break;
      case 'INVALID_INPUT':
        // Bad input (corrupt image, etc.)
        break;
      case 'API_ERROR':
        // General API error
        break;
    }
  }
}

License

MIT

Keywords

ocr

FAQs

Package last updated on 02 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts