Created
November 28, 2024 22:47
-
-
Save symisc/1907c7dcbc1c03791b22c4ac9323f211 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
=begin | |
* 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. | |
=end | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
api_key = 'PIXLAB_API_KEY' # Replace with your PixLab API Key from https://console.pixlab.io | |
image_url = 'http://i.stack.imgur.com/oJY2K.png' # Passport Input Image Sample | |
# Target API Endpoint located at: https://api.pixlab.io/docscan | |
# Documentation of the DOCSCAN API Endpoint is located at: https://pixlab.io/ekyc/docscan | |
uri = URI("https://api.pixlab.io/docscan?img=#{URI.encode_www_form_component(image_url)}&type=passport&key=#{api_key}") | |
# Make the GET Request. You can switch to the POST method if you prefer uploading your image directly | |
response = Net::HTTP.get(uri) | |
reply = JSON.parse(response) | |
if reply['status'] != 200 | |
# Handle errors | |
puts reply['error'] | |
else | |
# Print the Passport scan result | |
puts "User Cropped Face: #{reply['face_url']}" | |
puts "Passport Scanned Fields: " | |
puts "\tIssuing Country: #{reply['fields']['issuingCountry']}" | |
puts "\tFull Name: #{reply['fields']['fullName']}" | |
puts "\tDocument Number: #{reply['fields']['documentNumber']}" | |
puts "\tCheck Digit: #{reply['fields']['checkDigit']}" | |
puts "\tNationality: #{reply['fields']['nationality']}" | |
puts "\tDate Of Birth: #{reply['fields']['dateOfBirth']}" | |
puts "\tSex: #{reply['fields']['sex']}" | |
puts "\tDate Of Expiry: #{reply['fields']['dateOfExpiry']}" | |
puts "\tPersonal Number: #{reply['fields']['personalNumber']}" # Optional field | |
puts "\tFinal Check Digit: #{reply['fields']['finalcheckDigit']}" | |
end |
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.