Passport OCR Java

The Java client library supports the passport API for extracting data from passports.

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

Quick Start

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

// Load a file from disk and parse it
PassportResponse passportResponse = mindeeClient.loadDocument("./4a16b1d-passport_pic.jpg").parse(ReceiptResponse.class);

// Print a summary of the parsed data;


-----Passport data-----
Filename: passport.jpeg
Given names: HENERT
Country: GBR
ID Number: 707797979
Issuance date: 2012-04-22
Birth date: 1995-05-20
Expiry date: 2017-04-22
MRZ 1: P<GBRPUDARSAN<<HENERT<<<<<<<<<<<<<<<<<<<<<<<
MRZ 2: 7077979792GBR9505209M1704224<<<<<<<<<<<<<<00
MRZ: P<GBRPUDARSAN<<HENERT<<<<<<<<<<<<<<<<<<<<<<<7077979792GBR9505209M1704224<<<<<<<<<<<<<<00

Extracted Fields

Depending on the field type specified, additional attributes can be extracted from the Passport object.

Using the above passport example, the following are the basic fields that can be extracted.

ID/Passport Document Information


Id Number

  • id_number of type Field : Passport/ID Number from the image;

Issuance Date

  • issuanceDate of type Date : Date of issue for the ID
LocalDate issuanceDate = passportResponse.getPassport().getIssuanceDate().getValue();

Expiry Date

  • expiryDate of type Date : Date of expiry for the ID
LocalDate exDate = passportResponse.getPassport().getExpiryDate().getValue();

Passport Owner Information


  • surname of type Field : Passport Owner's Surname;

Given Names

  • givenNames of type List< Field > : a list of given names of the passport owner


  • gender of type Field : Passport Owner's gender (M/F);

Full Name

  • fullName of type Field : Passport Owner's calculated Full Name from their First and Last Name;

Birth Place

  • birthPlace of type Field : Passport Owner's place of birth;

Date of Birth

  • birthDate of type Date : Passport Owner's place of birth
LocalDate birthDate = passportResponse.getPassport().getBirthDate().getValue();

Machine Readable Zone


  • mrz1 of type Field : First line of the machine readable zone;


  • mrz2 of type Field : Second line of the machine readable zone;


  • mrz2 of type Field : Reconstructed MRZ from MRZ1 and MRZ2;


Slack Logo IconSlack Logo Icon  Join our Slack

Did this page help you?