Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active May 7, 2026 01:30
Show Gist options
  • Select an option

  • Save symisc/da8acfec3e9becdac3a290a36a8d3597 to your computer and use it in GitHub Desktop.

Select an option

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://pixlab.io/id-scan-api/docscan
/*
* Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint
* documented at: https://pixlab.io/id-scan-api/docscan
*
* Refer to the official documentation at: https://pixlab.io/id-scan-api/docscan
* for the API reference guide and more code samples.
*/
async function scanDocument() {
try {
const apiKey = 'PIXLAB_API_KEY'; // Your PixLab API key. Get yours from: https://console.pixlab.io
const imageUrl = 'http://i.stack.imgur.com/oJY2K.png'; // Image URL to scan if available
const url = 'https://api.pixlab.io/docscan'; // DOCSCAN API Endpoint
const data = {
img: imageUrl,
type: 'passport', // Example: "idcard", "driver_license", "passport", etc. or "unknown".
key: apiKey
};
const reply = await fetch(url, {
method: 'POST', // You can switch to GET if the image URL is publicly available
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then(response => response.json());
if (reply.status !== 200) {
console.error(reply.error);
} else {
// Dump everything the scanner returned to us
console.log(JSON.stringify(reply, null, 4));
// Typical JSON output using specimen data:
//
// {
// "type": "DRIVER LICENSE",
// "face_url": false,
// "fields": {
// "documentNumber": "99 999 999",
// "fullName": "JANICE ANN SAMPLE",
// "issuingDate": "2016-10-05",
// "expiryDate": "2020-08-05",
// "dateOfBirth": "1969-08-04",
// "address": "123 MAIN STREET APT. 1 HARRISBURG, PA 17101-0000",
// "issuingCountry": "USA",
// "gender": "female",
// "issuingState": "PA"
// },
// "status": 200
// }
}
} catch (error) {
console.error('Error:', error);
}
}
scanDocument();
@symisc

symisc commented Nov 28, 2024

Copy link
Copy Markdown
Author

Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint documented at: https://pixlab.io/id-scan-api/docscan

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/id-scan-api/docscan for the API reference guide and more code samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment