A8Flow Parser
A8 Parser tools consist of a collection of parsers, classifiers, and masking tools. Here is a current list of the Parsers.
- Pan
- Aadhaar- front
- Aadhaar- back
- Aadhaar- mask
- Voter Id
- Driving Licence
- Classifier
- PAN, AADHAAR, Driver's License (DL), Voter ID, Passport or OTHER
API Documentaion
BASE URL https://api-parser-uat.autonom8.com. Use your API KEY provisioned by A8parser.
Sample Curl
curl --location --request POST '{{BASE_URL}}/{{TYPE}}' \
--header 'x-api-key: {{X_API_KEY}}' \
--header 'version: {{API_VERSION}}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"file": "{BASE64 IMAGE STRING}"
}'
- PAN: TYPE - pan, API_VERSION - 0.2
- AADHAR: TYPE - aadhar, API_VERSION - 0.3
- Passport: TYPE - passport, API_VERSION - 0.2
- Cheque: TYPE - cheque, API_VERSION - 0.2
Integration SDK
This SDK parses out details from a PAN/Aadhaar/Driver's License/Passport/Voter ID/Cheque image taken by a mobile camera or an image chosen from the Gallery. It can also have an option to produce masked aadhar image.
Getting Started
These instructions will provide you a copy of the project that will be up and running on your local machine for development and testing purposes.
Pre-Requirements
- AndroidX Project
- Min SDK 19
Installation
Step 1: Add the maven repository to your build file. Add it in your root build.gradle at the end of repositories.
allprojects {
repositories {
...
maven {
url 'https://maven.autonom8.com/artifactory/gradle-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
}
Step 2: Add the dependencies.
dependencies {
implementation 'com.autonom8.parser:a8parser:3.0.+'
}
✅ That's it! The first time you request a project; Maven checks out the code, builds it and serves the build artifacts.
Step 3: Now, sync the project.
Using The Parser
Step 1: Declare A8Parser.
class MainActivity extends AppCompatActivity {
//..
A8Parser a8Parser;
//..
Step 2: Initialize A8Parser Instance. Pass the License Key to initialize() method.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
a8Parser = A8Parser.getInstances();
a8Parser.initialize(context, "<API KEY>"); //apiKey is the license key provided by autonom8
Enable/Disbale the quality check and gallery pick.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
a8Parser = A8Parser.getInstances();
A8ParserOptions options = new A8ParserOptions.Builder().setShowGallery(false).setEnableQualityCheck(true).build();
a8Parser.initialize(this, "<API KEY>");
a8Parser.setParserOption(options);
//..
}
// Or on demand
a8Parser.setParserOption(new A8ParserOptions.Builder().setEnableQualityCheck(true).setShowGallery(true).build());
Step 3: Use callback(A8Parser.OnParseResult) method of pan/aadhar wherever needed.
Pan Card
a8Parser.getPan(new A8Parser.OnParseResult<PanDetails>() {
@Override
public void onResult(PanDetails panDetails) {
//Result of Pan Card
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Aadhar Card
boolean canMaskAadharNumber = false; // true to enable masking
String side = null;
a8Parser.getAadhar(canMaskAadharNumber, side, new A8Parser.OnParseResult<AadharDetails>() {
@Override
public void onResult(AadharDetails aadharDetails) {
//Result of Aadhar Card
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Driving License Details
a8Parser.getDrivingLicenseDetails(new A8Parser.OnParseResult<DrivingLicenseDetails>() {
@Override
public void onResult(DrivingLicenseDetails drivingLicenseDetails) {
//Result of Driving License
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Cheque Details
a8Parser.getChequeDetails(new A8Parser.OnParseResult<ChequeDetails>() {
@Override
public void onResult(ChequeDetails ChequeDetails) {
//Result of Cheque
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Passport Details
String side = "front";
a8Parser.getPassportDetails(new A8Parser.OnParseResult<PassportDetails>() {
@Override
public void onResult(PassportDetails passportDetails) {
//Result of Passport Details
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Voter ID Details
a8Parser.getPassportDetails(new A8Parser.OnParseResult<VoterIdDetails>() {
@Override
public void onResult(VoterIdDetails VoterIdDetails) {
//Result of VoterId Details
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Get Image from A8Parser
Parse result with image source
Using A8Parser.OnParseResultWithImage callback to get details and source of the image captured by A8Parser.
a8Parser.getParsedImage(new OnParseImage() {
@Override
public void onResult(String imageSource, String type) {
// Image Source
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Parse Result
Pan Details
@Override
public void onResult(PanDetails panDetails) {
Log.d("Name:",panDetails.getName());
Log.d("FathersName:",panDetails.getFathersName());
Log.d("AccountNumber:",panDetails.getAccountNumber());
Log.d("Date Of Birth:",panDetails.getDob());
}
Parse Error
@Override
public void OnError(ParseError error) {
// error case
error.printTrace(); // print trace
Log.e("ParseError", "Code:"+ error.getCode()); // error code
Log.e("ParseError", "Reason:"+ error.getReason()); // error reason with stacktrace
Log.e("ParseError", "Message:"+ error.getMessage()); // error readable message
}
❕ Note: Data depends on parser response. One or more fields could be null. So, do a null check before consuming data.
Pan Details With Image
@Param String source // Base64 encoded image string.
a8Parser.getPanDetails(new A8Parser.OnParseResultWithImage<PanDetails>() {
@Override
public void onResult(PanDetails panDetails, String source) {
// Do null check before consume data
if(panDetails != null) {
// Your code goes here
}
// Sample Code to consume image source
byte[] imageBytes = Base64.decode(source, Base64.DEFAULT);
Bitmap decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imageView.setImageBitmap(decodedImage);
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Aadhar Details With Masked Image
// @Param set boolean value (true or false) to Enable or Disable masking.
a8Parser.getAadharDetails(true, null, new A8Parser.OnParseResultWithImage<AadharDetails>() {
@Override
public void onResult(AadharDetails aadharDetails, String source) {
// Do null check before consume data
if(aadharDetails != null) {
// Your code goes here
}
// Sample Code to consume image source
byte[] imageBytes = Base64.decode(source, Base64.DEFAULT);
Bitmap decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imageView.setImageBitmap(decodedImage);
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Parse Results Image Quality
a8Parser.getPanDetails(new A8Parser.OnParseResultWithImage<PanDetails>() {
@Override
public void onResult(PanDetails panDetails, String source) {
// Do null check before consume data
if(panDetails != null) {
// Your code goes here
}
ImageDetails parseInfo = panDetails.getImageDetails();
/**
getQualityPercentage() returns (int) 0-100.
Above 90 will be denote as good quality.
If returns (int) -1 doesnt have image details
**/
parseInfo.getQualityPercentage();
/**
Image resolution mentioned as pixcel.
**/
parseInfo.getImageResolution();
}
}, new OnParseError() {
@Override
public void OnError(ParseError error) {
// Error case
}
});
Picture Quality [Optional]
@Override
public void onCreate() {
//...
/**
Values can be LOW, HIGH, MEDIUM [default:HIGH]
**/
a8Parser.setPictureQuality(PictureSize.MEDIUM)
//...
}
Parse Custom API
@Override
protected void onCreate(Bundle savedInstanceState) {
//..
a8Parser.setPanApi(String URL,String version);
a8Parser.setAadharApi(String URL,String version)
a8Parser.setDrivingLicenseApi(String drivingLicenseUrl,String version)
a8Parser.setChequeApi(String chequeUrl,String version);
a8Parser.setPassportApi(String passportUrl,String version);
a8Parser.setVoterIdApi(String voterIdUrl,String version);
//..
}
Classify Image with Parser Details
a8Parser.getImageClassifierParserDetails(new A8Parser.OnParseResultWithImage<ParserDetails>() {
@Override
public void onResult(ParserDetails result, String source, String type) {
if(result != null) {
// Your code goes here
}
byte[] imageBytes = Base64.decode(source, Base64.DEFAULT);
Bitmap decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
Log.i("TESting", "onResult: imaByte lenght-" + imageBytes.length + ", ");
Log.e("TESting", "bm size: " + decodedImage.getByteCount() / 1024); // 942
Log.e("TESting", "byte size: " + imageBytes.length / 1024); // 8
}
});