Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active July 3, 2024 01:49
Show Gist options
  • Select an option

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

Select an option

Save symisc/690a5bbd65cf42db382cbd1c5cb6c24a 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 IS Driver License extract the license 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={ # swtich to POST if you want to upload the picture directly
'img':'https://www.aulicense.com/wp-content/uploads/2020/12/USA-DRIVERS-LICENSE.jpg', # US Driver license input image
'type':'driver_license', # Type of document we are a going to scan, hence US driver license
'country': 'usa', # Country of origin
'key':'PIXLAB_API_KEY' # Your PixLab API Key - Get yours from https://console.pixlab.io/
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print (f"User Cropped Face: {reply['face_url']}\n")
print ("Extracted Fields:\n\t")
# Display all extracted fields from the input US driver license image
print (f"Issuing Country: {reply['fields']['country']}\n\t")
print (f"Issuing State: {reply['fields']['issuingState']}\n\t")
print (f"Issuing State Code: {reply['fields']['issuingStateCode']}\n\t")
print (f"Full Name: {reply['fields']['fullName']}")
print (f"License Number: {reply['fields']['licenseNumber']}\n\t")
print (f"Address: {reply['fields']['address']}\n\t")
print (f"Date Of Birth: {reply['fields']['dateOfBirth']}\n\t")
print (f"issuing Date: {reply['fields']['issuingDate']}\n\t")
print (f"Date Of Expiry: {reply['fields']['expiryDate']}\n\t")
print (f"Gender: {reply['fields']['gender']}\n\t")
@symisc
Copy link
Author

symisc commented Jun 27, 2024

Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint.

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