IATA BCBP
Overview
The parser supports up to version 8 of the International Air Transport Association Bar Coded Boarding Pass (IATA-BCBP) standard. The latest IATA-BCBP specifications can be obtained from International Air Transport Association.
Sample usage for IATA-BCBP parser and Barcode Capture
First, you need to create a DataCaptureContext, access a Camera and create an IATA-BCBP parser:
DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey(SCANDIT_LICENSE_KEY);
Camera camera = Camera.getDefaultCamera(BarcodeCapture.createRecommendedCameraSettings());
camera.applySettings(BarcodeCapture.createRecommendedCameraSettings());
dataCaptureContext.setFrameSource(camera);
camera.switchToDesiredState(FrameSourceState.ON);
BarcodeCaptureSettings barcodeCaptureSettings = new BarcodeCaptureSettings();
BarcodeCapture barcodeCapture = BarcodeCapture.forDataCaptureContext(dataCaptureContext, barcodeCaptureSettings);
Parser parser = Parser.forFormat(dataCaptureContext, ParserDataFormat.IATA_BCBP);
Then, you need to implement BarcodeCaptureListener:
class MyBarcodeCaptureListener implements BarcodeCaptureListener {
@Override
public void onBarcodeScanned(
@NonNull BarcodeCapture barcodeCapture,
@NonNull BarcodeCaptureSession session,
@NonNull FrameData frameData
) {
if (session.getNewlyRecognizedBarcode() == null) return;
Barcode barcode = session.getNewlyRecognizedBarcode();
String data = barcode.getData();
try {
ParsedData parsedData = parser.parseString(data);
/*
* Extract the fields relevant to your use case. Below, for example, we extract the passenger name,
* which is represented as a list of Strings (["FirstName", "LastName"]), seat number which is a string,
* and flightDate, which is represented as a map with keys "year", "month", "day".
*/
List<String> passengerName = (List) parsedData.getFieldsByName().get("passengerName").getParsed();
String sedat = (String) parsedData.getFieldsByName().get("seatNumber").getParsed();
Map<String, Object> flightDate = (Map<String, Object>) parsedData.getFieldsByName().get("flightDate").getParsed();
int year = flightDate.get("year");
int month = flightDate.get("month");
int day = flightDate.get("day");
// Do something with the extracted fields.
} catch (RuntimeException e) {
message = e.getMessage();
}
// Other callbacks omitted for brevity.
}
Finally, add the listener to the mode to receive scan results:
barcodeCapture.addListener(new MyBarcodeCaptureListener());
For details, go to the API docs.
Examples
Parsing the following code (without the quotes) given a reference year of 2024:
"M1DESMARAIS/LUC EABC123 YULFRAAC 0834 226F001A0025 100"
will result in the following JSON output:
[
{
"name": "formatCode",
"parsed": "M",
"rawString": "M"
},
{
"name": "numberOfLegsEncoded",
"parsed": 1,
"rawString": "1"
},
{
"name": "passengerName",
"parsed": [
"LUC",
"DESMARAIS"
],
"rawString": "DESMARAIS/LUC"
},
{
"name": "electronicTicketIndicator",
"parsed": "E",
"rawString": "E"
},
{
"name": "legs",
"parsed": [
{
"checkInSequenceNumber": "0025",
"compartmentCode": "F",
"flightDate": {
"day": 13,
"month": 8,
"year": 2024
},
"flightNumber": "0834",
"fromAirport": "YUL",
"operatingCarrierDesignator": "AC",
"operatingCarrierPNR": "ABC123",
"passengerStatus": "1",
"seatNumber": "001A",
"toAirport": "FRA"
}
],
"rawString": "ABC123 YULFRAAC 0834 226F001A0025 1"
}
]
Exposed Fields
The names of the fields correspond to their names from the IATA BCBP spec, written in lower came case. For further details about specific items, please refer to the IATA Resolution 792 BCBP specifications.
Fields can be Mandatory (M) or Conditional (C), and in either case, are either top-level or associated with Legs (L).
Element Name |
Meaning |
M, C, L |
Value Type |
Notes |
---|---|---|---|---|
formatCode |
Format code |
M |
string |
Always ‘M’ |
numberOfLegsEncoded |
Number of legs |
M |
integer |
1 or greater |
legs |
Details for each leg of the trip |
M |
array of json objects |
|
passengerName |
Passenger’s first name and last name |
M |
array of two strings |
Names are truncated as required to fit within the total 19 characters available. |
electronicTicketIndicator |
Electronic ticket indicator |
M |
string |
E if passenger is travelling on an electronic ticket. |
passengerDescription |
The type of passenger |
C |
string |
0 for adult, 1 for male, 2 for female, 3 for child, etc… |
sourceOfCheckin |
Where the passenger checked in |
C |
string |
W for web, K for airport kiosk, R for remote, etc… |
sourceofBoardingPassIssuance |
Where the boarding ass was issued |
C |
string |
W for web, K for airport kiosk, R for remote, etc… |
dateOfIssuance |
Date the boarding pass was issued |
C |
key/value pairs:
with YYYY, MM, DD integers |
|
versionNumber |
BCBP version number |
C |
string |
Current version is 8. |
documentType |
Document type |
C |
string |
B for boarding pass, I for itinerary receipt. |
airlineDesignatorOfIssuer |
Designator of the airline which issued the boarding pass |
C |
string |
|
baggageTagLicensePlateNumbers |
Baggage tag license plate numbers |
C |
array of strings |
Each string in the array represents the license plate number for a single item of baggage. |
securityDataType |
The type of security used to protect the BCBP. |
C |
string |
|
securityData |
The security data used to prevent tampering of the BCBP data. |
C |
string |
|
operatingCarrierPNR |
Operating carrier PNR code |
L,M |
string |
|
fromAirport |
Three letter origin airport / city code. |
L,M |
string |
|
toAirport |
Three letter destination airport / city code. |
L,M |
string |
|
operatingCarrierDesignator |
Airline code for the operating carrier. |
L,M |
string |
Can be either the two letter or the three letter designator. |
flightNumber |
Actual flight number |
L,M |
string |
|
flightDate |
Date of the flight. |
L,M |
key/value pairs:
with YYYY, MM, DD integers |
|
compartmentCode |
Compartment code. |
L,M |
string |
F (first class), J (business class), Y (economy/coach), etc… See resolution IATA 728 for full list. |
seatNumber |
Seat number. |
L,M |
string |
Seat number if one has been assigned. Can also be e.g. GATE or STBY. |
checkInSequenceNumber |
Five character check-in sequence number. |
L,M |
string |
|
passengerStatus |
Passenger status. |
L,M |
string |
0 for passenger not checked in, 1 for passenger checked in, 2 for baggage checked in but passenger not checked in, etc.. |
airlineNumericCode |
Three characters representing the airline code. |
L,C |
string |
|
serialNumber |
Serial number of the document. |
L,C |
string |
|
selecteeIndicator |
Whether the passenger is a selectee or not. |
L,C |
string |
|
internationalDocumentationVerification |
Whether the passenger requires travel document verification or not. |
L,C |
string |
|
marketingCarrierDesignator |
Marketing carrier designator. |
L,C |
string |
May be the same as the operating carrier. |
frequentFlyerAirlineDesignator |
Airline code for the FFP. |
L,C |
string |
May be the two character or three character code. |
frequentFlyerNumber |
Frequent flyer number. |
L,C |
string |
13-16 characters in length. |
idIndicator |
Codes for indicating industry discounts or agency discounts. |
L,C |
string |
|
freeBaggageAllowance |
Free baggage allowance. |
L,C |
string |
Will indicate free allowance in pieces (PC), kilos (K) or pounds (P) |
fastTrack |
Passenger is fast tracked. |
L,C |
string |
Y for yes, N for no. Blank if unqualified. |
airlineInfo |
For airline use. |
L,C |
string |
Can be of arbitrary length but limited by total available size of section. |
Parser Options
Following options can be set to fine-tune the behavior of the parser:
- “strictMode”: boolean (default:true)
Controls the strictness of the parser. When strictMode is set to true, every error in the input (invalid characters etc.) is treated as an error. Parsing is aborted upon encountering the first error. When strictMode is set to false, parsing continues for non-critical errors. The encountered problems can be queried for each field separately via the issues property, although for the “legs” fields the errors will propagate to the result.
- “referenceYear”: int? (default: null)
The date of issuance indicates the final digit of the year of issuance. To thus deduce the correct decade without ambiguity, the “referenceYear” may be set in the parser options.