All Products
Search
Document Center

ID Verification:Call examples of SDK for Python

Last Updated:Oct 30, 2023

This topic provides examples on how to use ID Verification- KYC (Global) SDK for Python. KYC is short for Know Your Customer.

Prerequisites

Python 3.0 or later is installed.

Install the SDK

To obtain the SDK source code, visit Package of SDK for Python.

pip install alibabacloud_cloudauth_intl20220809==1.3.1
pip install alibabacloud_credentials==0.3.2

Call examples

Call example of the Initialize operation

from alibabacloud_cloudauth_intl20220809.client import Client as CloudauthClient
from alibabacloud_cloudauth_intl20220809 import models as cloudauth_models
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_credentials.client import Client as CredClient


class Initialize:
    def __init__(self):
        pass

    @staticmethod
    def main() -> None:
        # Build client
        cred=CredClient()
        config = open_api_models.Config(
            credential=cred,
            endpoint="cloudauth-intl.cn-hongkong.aliyuncs.com"
        )
        client = CloudauthClient(config)

        # Build request
        request = cloudauth_models.InitializeRequest(
            merchant_biz_id = "****",
            merchant_user_id = "****",
            meta_info = "{\"apdid****mVer\":\"1.0.0\"}",
            product_code ="KYC_GLOBAL",
            doc_type = "01560001",
            doc_scan_mode = "manual",
            product_flow ="DOC_FACE",
            callback_url = "https://www.aliyun.com",
            callback_token ="NY4******"
        )

        # Invoke API
        response = client.initialize(request)

        # Get result
        print(response.status_code)
        print(response.body.request_id)
        print(response.body.result.transaction_id)

if __name__ == '__main__':
    Initialize.main()

Call example of the CheckResult operation

from alibabacloud_cloudauth_intl20220809.client import Client as CloudauthClient
from alibabacloud_cloudauth_intl20220809 import models as cloudauth_models
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_credentials.client import Client as CredClient

 
class CheckResult:
    def __init__(self):
        pass
 
    @staticmethod
    def main() -> None:
        # Build client
        cred=CredClient()
        config = open_api_models.Config(
            credential=cred,
            endpoint="cloudauth-intl.cn-hongkong.aliyuncs.com"
        )
        client = CloudauthClient(config)
 
        # Build request
        request = cloudauth_models.CheckResultRequest(
            transaction_id="hks99********8f902",
            merchant_biz_id="****",
            is_return_image="Y"
        )
 
        # Invoke API
        response = client.check_result(request)
 
        # Get result
        print(response.status_code)
        print(response.body.request_id)
        print(response.body.result.passed)
        print(response.body.result.sub_code)
        print(response.body.result.ext_face_info)
        print(response.body.result.ext_id_info)        
 
 
if __name__ == '__main__':
    CheckResult.main()