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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@metolabs/mx-bank-receipt-reader

v0.0.10

Published

A library for reading and extracting data from Mexican bank receipts (browser and Node.js compatible)

Downloads

33

Readme

Mexican Bank Receipt Reader

A JavaScript library for extracting structured data from Mexican bank receipts using OCR. Works in both Node.js and browser environments.

Features

  • Extract data from bank receipt images (SPEI transfers, third-party transfers)
  • Automatic bank detection
  • Works in both Node.js (CLI) and browser environments
  • Supports multiple Mexican banks:
    • BBVA
    • Banorte
    • Santander
    • HSBC
    • Scotiabank
    • Afirme
    • BanBajio
    • Banregio

Installation

NPM

npm install mx-bank-receipt-reader

Yarn

yarn add mx-bank-receipt-reader

CLI Usage

The package includes a command-line interface for processing receipt images:

Using the command syntax (recommended)

# Process a single receipt image
bank-reader process /path/to/receipt.jpg

# Process multiple receipt images
bank-reader process /path/to/receipt1.jpg /path/to/receipt2.jpg

# Process all images in a directory
bank-reader process /path/to/receipts/

# Process with JSON output format
bank-reader process /path/to/receipt.jpg --format json

Using the parameter syntax

# Process a receipt image
bank-reader --image /path/to/receipt.jpg

# Process with JSON output format
bank-reader --image /path/to/receipt.jpg --format json

# Alternative syntax
bank-reader -i /path/to/receipt.jpg -f json

CLI Options

Commands:
  process <files...>    Process one or more receipt images

Options:
  -i, --image <path>    Path to receipt image file
  -f, --format <format> Output format: json, text (default: text)
  -h, --help            Show this help

Browser Usage

Using ES Modules

import BankReceiptReader from 'mx-bank-receipt-reader';

const reader = new BankReceiptReader();

// Process an image (File, Blob, or HTMLImageElement)
const fileInput = document.getElementById('receipt-image');
fileInput.addEventListener('change', async (event) => {
  const file = event.target.files[0];
  
  try {
    const result = await reader.readReceipt(file);
    
    if (result && result.success) {
      console.log('Bank:', result.bank);
      console.log('Type:', result.type);
      console.log('Data:', result.data);
    } else {
      console.error('Could not identify bank or extract data');
    }
  } catch (error) {
    console.error('Error processing receipt:', error);
  }
});

Using Script Tag

<script src="node_modules/mx-bank-receipt-reader/dist/bank-receipt-reader.browser.js"></script>
<script>
  const reader = new BankReceiptReader();
  
  // Process an image (File, Blob, or HTMLImageElement)
  const fileInput = document.getElementById('receipt-image');
  fileInput.addEventListener('change', async (event) => {
    const file = event.target.files[0];
    
    try {
      const result = await reader.readReceipt(file);
      
      if (result && result.success) {
        console.log('Bank:', result.bank);
        console.log('Type:', result.type);
        console.log('Data:', result.data);
      } else {
        console.error('Could not identify bank or extract data');
      }
    } catch (error) {
      console.error('Error processing receipt:', error);
    }
  });
</script>

API Reference

BankReceiptReader

The main class for processing bank receipts.

Constructor

const reader = new BankReceiptReader();

Methods

readReceipt(imageInput)

Processes a receipt image and extracts structured data.

  • Parameters:
    • imageInput (Browser: File, Blob, HTMLImageElement | Node.js: string) - The receipt image to process
  • Returns: Promise - A promise that resolves to an object with the following properties:
    • success (boolean) - Whether the processing was successful
    • bank (string) - The identified bank (e.g., 'bbva', 'santander')
    • type (string) - The receipt type (e.g., 'spei', 'third_party')
    • data (Object) - The extracted data, which may include:
      • account_id (string) - The account ID
      • amount (number) - The transaction amount
      • reference (string) - The reference number
extractText(imageInput)

Extracts text from an image using OCR.

  • Parameters:
    • imageInput (Browser: File, Blob, HTMLImageElement | Node.js: string) - The image to process
  • Returns: Promise - A promise that resolves to the extracted text
identifyBank(text)

Identifies the bank and receipt type from OCR text.

  • Parameters:
    • text (string) - The OCR text to analyze
  • Returns: Object|null - An object with bank information or null if no bank was identified

Supported Banks and Receipt Types

| Bank | SPEI Transfers | Third-Party Transfers | |------|----------------|------------------------| | BBVA | ✅ | ✅ | | Banorte | ✅ | ✅ | | Santander | ✅ | ✅ | | HSBC | ✅ | ❌ | | Scotiabank | ✅ | ❌ | | Afirme | ✅ | ❌ | | BanBajio | ✅ | ❌ | | Banregio | ✅ | ✅ |

Requirements

  • Node.js 14+ (for CLI usage)
  • Modern browser with ES6 support (for browser usage)

License

MIT