Automatically Extracting Receipts Using the Mindee Client Libraries

The Node.js library implementation differs from our other supported languages, see the Node.js dedicated tutorial instead.

Overview

When to Use This Feature

Use the Multi-Receipts Detector API when you have:

  • A single image containing multiple receipts

  • The need to process each receipt individually without manual separation

  • A desire to streamline receipt processing workflows

The Multi-Receipts Detector API scans the contents of a file, identifies the coordinates of individual receipts, and allows for their extraction and separate processing.

Note: For PDFs, the API applies this principle at a page level, treating each page as a separate image.

Prerequisites

Before you begin, ensure you have:

Sample File

For this tutorial, we'll use the following sample multi-receipt image:

Sample Multi-Receipt Image

When preparing your own files, ensure that:

  • Receipts are clear, unstained, and properly unfolded

  • Receipts don't overlap and are fully within the image

  • Receipts are aligned in roughly the same direction

  • No other types of documents are mixed in with the receipts

Basic Setup

  1. Import the necessary classes from the Mindee library.

  2. Initialize the Mindee client with your API key.

  3. Load the input file.

Processing the Input

Detect Multiple Receipts

Use the Multi-Receipts Detector API to identify individual receipts in the image:

Extract Individual Receipts

Extract the detected receipts from the original image:

Process Each Receipt

Loop through the extracted receipts and process each one with the Receipt OCR API:

Example Output

After processing, you'll receive detailed information about each receipt. Here's a sample output:

Full Script

Best Practices

  • Handle potential errors and exceptions in your code.

  • Implement rate limiting or delays between API calls to avoid overloading the server.

  • Consider saving extracted receipts locally if needed for further processing or record-keeping.

  • Ensure your input images are of good quality for optimal results.

Troubleshooting

If you encounter issues:

  1. Verify your API key and subscription status for both Multi-Receipts Detector and Receipt OCR APIs.

  2. Check the input file format and ensure it's supported.

  3. Review the API response for any error messages.

  4. Consult the Mindee API documentation for more detailed information.

Next Steps

  • Explore advanced features of the Mindee API.

  • Integrate the extracted data into your existing workflows.

  • Consider implementing batch processing for large volumes of receipts.

Last updated

Was this helpful?