Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active June 27, 2024 23:59
Show Gist options
  • Save symisc/c6e2dd6207dbc63d449b1ac265b6263a to your computer and use it in GitHub Desktop.
Save symisc/c6e2dd6207dbc63d449b1ac265b6263a 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
import requests
import json
# 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://ekyc.pixlab.io/docscan for the API reference guide and more code samples.
req = requests.get(
'https://api.pixlab.io/docscan',
params={
'img':'https://i.stack.imgur.com/oJY2K.png', # Passport Input Image
'type':'passport', # Type of document we are a going to scan
'key':'PIXLAB_API_KEY' # Get your PixLab API Key from https://console.pixlab.io
}
)
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print ("User Cropped Face: " + reply['face_url'])
print ("Raw MRZ Text: " + reply['mrz_raw_text'])
print ("Extracted Passport MRZ Fields:")
# Display all extracted MRZ fields
print ("\tIssuing Country: " + reply['fields']['issuingCountry'])
print ("\tFull Name: " + reply['fields']['fullName'])
print ("\tDocument Number: " + reply['fields']['documentNumber'])
print ("\tCheck Digit: " + reply['fields']['checkDigit'])
print ("\tNationality: " + reply['fields']['nationality'])
print ("\tDate Of Birth: " + reply['fields']['dateOfBirth'])
print ("\tSex: " + reply['fields']['sex'])
print ("\tDate Of Expiry: " + reply['fields']['dateOfExpiry'])
print ("\tPersonal Number: " + reply['fields']['personalNumber']) # Optional field and may not be returned when not set by the issuing country.
print ("\tFinal Check Digit: " + reply['fields']['finalcheckDigit'])
@symisc
Copy link
Author

symisc commented Jun 19, 2024

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.

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