Receipt OCR Java

The java client library supports the receipt API for extracting data from receipts.

Using this sample receipt below, we are going to illustrate how to extract the data that we want using the client library.
sample receiptsample receipt

Quick Start


// Init a new client
Client mindeeClient = new Client("<YOUR_MINDEE_API_KEY>");

// Load a file from disk and parse it
ReceiptResponse receiptResponse = mindeeClient.loadDocument("./a74eaa5-c8e283b-sample_receipt.jpeg").parse(ReceiptResponse.class);

// Print a summary of the parsed data
logger.info(receiptResponse.documentSummary());

Output:

-----Receipt data-----
Total amount including taxes: 10.2
Total amount excluding taxes: 8.5
Date: 2016-02-26
Category: food
Time: 15:20
Merchant name: CLACHAN
Taxes: 1.7 20.0%
Total taxes: 1.7
Locale: en-GB; en; GB; GBP;
---------------------

Extracted Fields

Attributes that will be extracted from the document and available in the ReceiptResponse object:

Receipt Information

Category

  • categoryof type Field : Receipt category as seen on the receipt.
    The following categories are supported: toll, food, parking, transport, accommodation, gasoline, miscellaneous.
logger.info(receiptResponse.getReceipt().getCategory().getValue());

Date

  • date of type Date : The date the receipt was issued
LocalDate receiptDate = receiptResponse.getReceipt().getDate().getValue();

Time

  • time of type Time : The time the receipt was issued
LocalTime receiptTime = receiptResponse.getReceipt().getTime().getValue();

Locale

Supplier Information

Merchant Name

  • merchantName of type Field : Supplier name as written in the receipt.
logger.info(receiptResponse.getReceipt().getMerchantName().getValue());

Taxes and Amounts

Taxes

A list of the taxes seen on the receipt

  • taxes of type List < Tax >
receiptResponse.getReceipt().getTaxes()
      .stream()
      .map(Tax::getTaxSummary)
      .forEach(System.out::println);

Total Tax

The total tax for the receipt

logger.info(receiptResponse.getReceipt().getTotalTax().getValue());

Total Including Taxes

The total amount including taxes for the receipt

logger.info(receiptResponse.getReceipt().getTotalIncl().getValue());

Total Excluding Taxes

The total amount excluding taxes for the receipt

logger.info(receiptResponse.getReceipt().getTotalExcl().getValue());

 

Questions?
Slack Logo IconSlack Logo Icon  Join our Slack


Did this page help you?