npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@creativecodelabs/ocr

v1.0.0

Published

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

Readme

@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

| Field | Type | Description | |-------|------|-------------| | merchantName | string \| null | Store/merchant name | | merchantAddress | string \| null | Merchant address | | transactionDate | string \| null | Date (ISO format) | | totalAmount | string \| null | Total amount | | taxAmount | string \| null | Tax/VAT amount | | currency | string \| null | Currency code (USD, EUR, ZAR) | | paymentMethod | string \| null | Payment method if detected | | lineItems | ReceiptLineItem[] | Individual items | | confidence | object | Confidence scores (0-1) |

Invoice Fields

| Field | Type | Description | |-------|------|-------------| | vendorName | string \| null | Vendor/supplier name | | vendorAddress | string \| null | Vendor address | | customerName | string \| null | Customer/bill-to name | | customerAddress | string \| null | Customer address | | invoiceNumber | string \| null | Invoice number | | invoiceDate | string \| null | Invoice date | | dueDate | string \| null | Payment due date | | totalAmount | string \| null | Total amount | | subtotal | string \| null | Subtotal before tax | | taxAmount | string \| null | Tax amount | | currency | string \| null | Currency code | | poNumber | string \| null | Purchase order number | | lineItems | InvoiceLineItem[] | Line items | | confidence | object | Confidence 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