Last active
March 22, 2025 03:01
-
-
Save symisc/da8acfec3e9becdac3a290a36a8d3597 to your computer and use it in GitHub Desktop.
Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint documented at: https://ekyc.pixlab.io/docscan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint | |
* documented at: https://ekyc.pixlab.io/docscan | |
* | |
* In this example, given a Passport document, extract the passport holder face and convert/parse all Machine Readable Zone | |
* to textual content ready to be consumed by your application. | |
* | |
* PixLab recommend that you connect your AWS S3 bucket via the dashboard at https://console.pixlab.io | |
* so that any extracted face or MRZ crop is automatically stored on your S3 bucket rather than the PixLab one. | |
* This feature should give you full control over your analyzed media files. | |
* | |
* Refer to the official documentation at: https://pixlab.io/ekyc/docscan for the API reference guide and more code samples. | |
*/ | |
async function scanDocument() { | |
try { | |
const apiKey = 'PIXLAB_API_KEY'; // Your Pixlab API key. Get your from: https://console.pixlab.io | |
}; | |
const imageUrl = 'http://i.stack.imgur.com/oJY2K.png'; // Image URL to scan if available or upload direclty yours | |
const url = `https://api.pixlab.io/docscan`; // DOCSCAN API Endpoint | |
// Payload request | |
const data = { | |
img: imageUrl, // The ID image public URL if available or directly upload your own from your backend for more privacy | |
type: 'passport', // The document type we are going to scan such 'idcard', 'driver_license', 'passport', etc | |
key: apiKey // Your PixLab API key | |
}; | |
// Perform the request | |
const reply = await fetch(url, { | |
method: 'POST', // or GET in case the image URL is publicly available | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify(data) | |
}).then(response => response.json()); | |
// Processing result | |
if (reply.status !== 200) { | |
console.error(reply.error); | |
} else { | |
console.log("User Cropped Face: " + reply.face_url); | |
console.log("Extracted Fields: "); | |
console.log("\tIssuing Country: " + reply.fields.issuingCountry); | |
console.log("\tFull Name: " + reply.fields.fullName); | |
console.log("\tDocument Number: " + reply.fields.documentNumber); | |
console.log("\tCheck Digit: " + reply.fields.checkDigit); | |
console.log("\tNationality: " + reply.fields.nationality); | |
console.log("\tDate Of Birth: " + reply.fields.dateOfBirth); | |
console.log("\tSex: " + reply.fields.sex); | |
console.log("\tDate Of Expiry: " + reply.fields.dateOfExpiry); | |
console.log("\tPersonal Number: " + reply.fields.personalNumber); | |
console.log("\tFinal Check Digit: " + reply.fields.finalcheckDigit); | |
} | |
} catch (error) { | |
console.error('Error:', error); | |
} | |
} | |
scanDocument(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint documented at: https://ekyc.pixlab.io/
Given a government issued passport document, extract the user face and parse all MRZ fields.
PixLab recommend that you connect your AWS S3 bucket via the dashboard at https://console.pixlab.io/ so that any extracted face or MRZ crop is automatically stored on your S3 bucket rather than the PixLab one. This feature should give you full control over your analyzed media files.
Refer to the official documentation at: https://ekyc.pixlab.io/docscan for the API reference guide and more code samples.