Package: idanalyzer
ID Analyzer Python SDKThis is a python SDK library forID Analyzer Identity Verification APIs, though all the APIs can be called with without the SDK using simple HTTP requests as outlined in thedocumentation, you can use this SDK to accelerate server-side development.We strongly discourage users to connect to ID Analyzer API endpoint directly from client-side applications that will be distributed to end user, such as mobile app, or in-browser JavaScript. Your API key could be easily compromised, and if you are storing your customer's information inside Vault they could use your API key to fetch all your user details. Therefore, the best practice is always to implement a client side connection to your server, and call our APIs from the server-side.InstallationInstall through PIPpipinstallidanalyzerCore APIID Analyzer Core APIallows you to perform OCR data extraction, facial biometric verification, identity verification, age verification, document cropping, document authentication (fake ID check), and paperwork automation using an ID image (JPG, PNG, PDF accepted) and user selfie photo or video. Core API has great global coverage, supporting over 98% of the passports, driver licenses and identification cards currently being circulated around the world.The sample code below will extract data from this sample Driver License issued in California, compare it with aphoto of Lena, and check whether the ID is real or fake.importidanalyzertry:# Initialize Core API with your api key and region (US/EU)coreapi=idanalyzer.CoreAPI("Your API Key","US")# Raise exceptions for API level errorscoreapi.throw_api_exception(True)# enable document authentication using quick modulecoreapi.enable_authentication(True,'quick')# perform scanresponse=coreapi.scan(document_primary="https://www.idanalyzer.com/img/sampleid1.jpg",biometric_photo="https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png")# All the information about this ID will be returned in response dictionaryprint(response)# Print document holder nameifresponse.get('result'):data_result=response['result']print("Hello your name is{}{}".format(data_result['firstName'],data_result['lastName']))# Parse document authentication resultsifresponse.get('authentication'):authentication_result=response['authentication']ifauthentication_result['score']>0.5:print("The document uploaded is authentic")elifauthentication_result['score']>0.3:print("The document uploaded looks little bit suspicious")else:print("The document uploaded is fake")# Parse biometric verification resultsifresponse.get('face'):face_result=response['face']ifface_result['isIdentical']:print("Face verification PASSED!")else:print("Face verification FAILED!")print("Confidence Score: "+face_result['confidence'])exceptidanalyzer.APIErrorase:# If API returns an error, catch itdetails=e.args[0]print("API error code:{}, message:{}".format(details["code"],details["message"]))exceptExceptionase:print(e)You could also set additional parameters before performing ID scan:coreapi.enable_vault(True,False,False,False)# enable vault cloud storage to store document information and imagecoreapi.set_biometric_threshold(0.6)# make face verification more strictcoreapi.enable_authentication(True,2)# check if document is real using module v2coreapi.enable_barcode_mode(False)# disable OCR and scan for AAMVA barcodes onlycoreapi.enable_image_output(True,True,"url")# output cropped document and face region in URL formatcoreapi.enable_dualside_check(True)# check if data on front and back of ID matchescoreapi.set_vault_data("user@example.com",12345,"AABBCC")# store custom data into vaultcoreapi.restrict_country("US,CA,AU")# accept documents from United States, Canada and Australiacoreapi.restrict_state("CA,TX,WA")# accept documents from california, texas and washingtoncoreapi.restrict_type("DI")# accept only driver license and identification cardcoreapi.set_ocr_image_resize(0)# disable OCR resizingcoreapi.verify_expiry(True)# check document expirycoreapi.verify_age("18-120")# check if person is above 18coreapi.verify_dob("1990/01/01")# check if person's birthday is 1990/01/01coreapi.verify_document_number("X1234567")# check if the person's ID number is X1234567coreapi.verify_name("Elon Musk")# check if the person is named Elon Muskcoreapi.verify_address("123 Sunny Rd, California")# check if address on ID matches with provided addresscoreapi.verify_postcode("90001")# check if postcode on ID matches with provided postcodecoreapi.enable_aml_check(True)# enable AML/PEP compliance checkcoreapi.set_aml_database("global_politicians,eu_meps,eu_cors")# limit AML check to only PEPscoreapi.enable_aml_strict_match(True)# make AML matching more strict to prevent false positivescoreapi.generate_contract("Template ID","PDF",{"email":"user@example.com"});# generate a PDF document autofilled with data from user IDToscan both front and back of ID:response=coreapi.scan(document_primary="id_front.jpg",document_secondary="id_back.jpg")To performbiometric video verification:response=coreapi.scan(document_primary="id_front.jpg",biometric_video="face_video.mp4",biometric_video_passcode="1234")Check out sample response array fields visitCore API reference.DocuPass APIDocuPassallows you to verify your users without designing your own web page or mobile UI. A unique DocuPass URL can be generated for each of your users and your users can verify their own identity by simply opening the URL in their browser. DocuPass URLs can be directly opened using any browser,  you can also embed the URL inside an iframe on your website, or within a WebView inside your iOS/Android/Cordova mobile app.DocuPass comes with 4 modules and you need tochoose an appropriate DocuPass modulefor integration.To start, we will assume you are trying toverify one of your user that has an ID of "5678"in your own database, we need togenerate a DocuPass verification request for this user. A uniqueDocuPass reference codeandURLwill be generated.importidanalyzertry:# Initialize Core API with your api key and region (US/EU)docupass=idanalyzer.DocuPass("Your API Key","Your Company Name Inc.","US")# Raise exceptions for API level errorsdocupass.throw_api_exception(True)# We need to set an identifier so that we know internally who we are verifying,# this string will be returned in the callback. You can use your own user/customer id.docupass.set_custom_id("5678")# Enable vault cloud storage to store verification resultsdocupass.enable_vault(True)# Set a callback URL where verification results will be sent,# you can use docupass_callback.php under this folder as a templatedocupass.set_callback_url("https://www.your-website.com/docupass_callback.php")# We want DocuPass to return document image and user face image in URL format.docupass.set_callback_image(True,True,1)# We will do a quick check on whether user have uploaded a fake IDdocupass.enable_authentication(True,"quick",0.3)# Enable photo facial biometric verification with threshold of 0.5docupass.enable_face_verification(True,1,0.5)# Users will have only 1 attempt for verificationdocupass.set_max_attempt(1)# We want to redirect user back to your website when they are done with verificationdocupass.set_redirection_url("https://www.your-website.com/verification_succeeded.html","https://www.your-website.com/verification_failed.html")# Create a mobile verification session for this userresponse=docupass.create_mobile()# Create Live Mobile Module# docupass.create_live_mobile()# Create URL Redirection Module# docupass.create_redirection()# Create Iframe Module# docupass.create_iframe()print(response)print("Scan the QR Code below to verify your identity: ")print(response['qrcode'])print("Or open your mobile browser and type in: ")print(response['url'])exceptidanalyzer.APIErrorase:# If API returns an error, catch itdetails=e.args[0]print("API error code:{}, message:{}".format(details["code"],details["message"]))exceptExceptionase:print(e)If you are looking to embed DocuPass into your mobile application, simply embed$result['url']inside a WebView. To tell if verification has been completed monitor the WebView URL and check if it matches the URLs set in setRedirectionURL. (DocuPass Live Mobile currently cannot be embedded into native iOS App due to OS restrictions, you will need to open it with Safari)Check out additional DocuPass settings:docupass.set_reusable(True)# allow docupass URL/QR Code to be used by multiple usersdocupass.set_language("en")# override auto language detectiondocupass.set_qrcode_format("000000","FFFFFF",5,1)# generate a QR code using custom colors and sizedocupass.set_welcome_message("We need to verify your driver license before you make a rental booking with our company.")# Display your own greeting messagedocupass.set_logo("https://www.your-website.com/logo.png")# change default logo to your owndocupass.hide_branding_logo(True)# hide footer logodocupass.restrict_country("US,CA,AU")# accept documents from United States, Canada and Australiadocupass.restrict_state("CA,TX,WA")# accept documents from california, texas and washingtondocupass.restrict_type("DI")# accept only driver license and identification carddocupass.verify_expiry(True)# check document expirydocupass.verify_age("18-120")# check if person is above 18docupass.verify_dob("1990/01/01")# check if person's birthday is 1990/01/01docupass.verify_document_number("X1234567")# check if the person's ID number is X1234567docupass.verify_name("Elon Musk")# check if the person is named Elon Muskdocupass.verify_address("123 Sunny Rd, California")# Check if address on ID matches with provided addressdocupass.verify_postcode("90001")# check if postcode on ID matches with provided postcodedocupass.set_custom_html_url("https://www.yourwebsite.com/docupass_template.html")# use your own HTML/CSS for DocuPass pagedocupass.sms_verification_link("+1333444555")# Send verification link to user's mobile phonedocupass.enable_phone_verification(True)# get user to input their own phone number for verificationdocupass.verify_phone("+1333444555")# verify user's phone number you already have in your databasedocupass.enable_aml_check(True)# enable AML/PEP compliance checkdocupass.set_aml_database("global_politicians,eu_meps,eu_cors")# limit AML check to only PEPsdocupass.enable_aml_strict_match(True)# make AML matching more strict to prevent false positivesdocupass.generate_contract("Template ID","PDF",{"somevariable":"somevalue"})# automate paperwork by generating a document autofilled with ID datadocupass.sign_contract("Template ID","PDF",{"somevariable":"somevalue"})# get user to review and sign legal document prefilled with ID dataNow you should write acallback scriptor awebhook, to receive the verification results.  VisitDocuPass Callback referenceto check out the full payload returned by DocuPass. Callback script is generally programmed in a server environment and is beyond the scope of this guide, you can check out ourPHP SDKfor creating a callback script in PHP.For the final step, you could create two web pages (URLS set viaset_redirection_url) that display the results to your user. DocuPass reference will be passed as a GET parameter when users are redirected, for example:https://www.your-website.com/verification_succeeded.php?reference=XXXXXXXXX, you could use the reference code to fetch the results from your database. P.S. We will always send callbacks to your server before redirecting your user to the set URL.DocuPass Signature APIYou can get user to review and remotely sign legal document in DocuPass without identity verification, to do so you need to create a DocuPass Signature session.# Initialize DocuPass API with your api key and region (US/EU)docupass=idanalyzer.DocuPass("Your API Key","Your Company Name Inc.","US")# Raise exceptions for API level errorsdocupass.throw_api_exception(True)# We need to set an identifier so that we know internally who is signing the document,# this string will be returned in the callback. You can use your own user/customer id.docupass.set_custom_id("CUSTOMER1234")# Enable vault cloud storage to store signed documentdocupass.enable_vault(True)# Set a callback URL where signed document will be sent,# you can use docupass_callback.php under this folder as a template to receive the resultdocupass.set_callback_url("https://www.your-website.com/docupass_callback.php")# We want to redirect user back to your website when they are done with document signing,# there will be no fail URL unlike identity verificationdocupass.set_redirection_url("https://www.your-website.com/document_signed.html","")""" More parametersdocupass.set_reusable(True) # allow docupass URL/QR Code to be used by multiple usersdocupass.set_language("en") # override auto language detectiondocupass.set_qrcode_format("000000","FFFFFF",5,1) # generate a QR code using custom colors and sizedocupass.hide_branding_logo(True) # hide footer logodocupass.set_custom_html_url("https://www.yourwebsite.com/docupass_template.html") # use your own HTML/CSS for DocuPass pagedocupass.sms_contract_link("+1333444555")  # Send signing link to user's mobile phone"""#Assuming in your contract template you have a dynamic field %{email} and you want to fill it with user emailprefill={"email":"user@example.com"}# Create a signature session for this userresponse=docupass.create_signature("Template ID","PDF",prefill)print(response)print("Scan the QR Code below to sign document: ")print(response['qrcode'])print("Or open your mobile browser and navigate to: ")print(response['url'])Once user has reviewed and signed the document, the signed document will be sent back to your server using callback under thecontract.document_urlfield, the contract will also be saved to vault if you have enabled vault.Vault APIID Analyzer provides free cloud database storage (Vault) for you to store data obtained through Core API and DocuPass. You can set whether you want to store your user data into Vault throughenable_vaultwhile making an API request with PHP SDK. Data stored in Vault can be looked up throughWeb Portalor via Vault API.If you have enabled Vault, Core API and DocuPass will both return a vault entry identifier string calledvaultid,  you can use the identifier to look up your user data:importidanalyzertry:# Initialize Core API with your api key and region (US/EU)vault=idanalyzer.Vault("Your API Key","US")# Get vault item with vault IDresponse=vault.get("Vault_id")print(response)exceptidanalyzer.APIErrorase:# If API returns an error, catch itdetails=e.args[0]print("API error code:{}, message:{}".format(details["code"],details["message"]))exceptExceptionase:print(e)You can also list some of the items in your vault:# List 5 items created on or after 2021/02/25# sort result by first name in ascending order, starting from first item.response=vault.list(filter=["createtime>=2021/02/25"],orderby="firstName",sort="ASC",limit=5,offset=0)Alternatively, you may have a DocuPass reference code which you want to search through vault to check whether user has completed identity verification:response=vault.list(filter=["docupass_reference=XXXXXXXXXXXXX"])Learn more aboutVault API.AML APIID Analyzer provides Anti-Money Laundering AML database consolidated from worldwide authorities,  AML API allows our subscribers to lookup the database using either a name or document number. It allows you to instantly check if a person or company is listed underany kind of sanction, criminal record or is a politically exposed person(PEP), as part of yourAML compliance KYC. You may also use automated check built within Core API and DocuPass.importidanalyzertry:# Initialize AML API with your api key and region (US/EU)aml=idanalyzer.AMLAPI("Your API Key","US")# Raise exceptions for API level errorsaml.throw_api_exception(True)# Set AML database to only search the PEP categoryaml.set_aml_database("global_politicians,eu_cors,eu_meps")# Search for a politicianresponse1=aml.search_by_name("Joe Biden")print(response1)# Set AML database to all databasesaml.set_aml_database("")# Search for a sanctioned ID numberresponse2=aml.search_by_id_number("AALH750218HBCLPC02")print(response2)exceptidanalyzer.APIErrorase:# If API returns an error, catch itdetails=e.args[0]print("API error code:{}, message:{}".format(details["code"],details["message"]))exceptExceptionase:print(e)Learn more aboutAML API.DemoCheck out/demofolder for more Python demos.SDK ReferenceCheck outID Analyzer Python SDK Reference