All Products
Search
Document Center

ID Verification:Use the SDK for Python

Last Updated:Nov 26, 2024

This topic describes how to integrate ID Verification - Know Your Customer (KYC) SDK for Python for the server-side-only solution of face verification and how to call the FaceCompare operation by using the SDK.

Prerequisites

Python 3.0 or later is installed.

Install dependencies

pip install alibabacloud_tea_openapi==0.2.5

Install the SDK

For more information about the source code of ID Verification - KYC SDK for Python, see Alibaba Cloud Cloudauth-intl SDK for Python.

pip install alibabacloud_cloudauth_intl20220809==1.0.7

Call examples

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


class Initialize:
    def __init__(self):
        pass

    @staticmethod
    def main() -> None:

        # Build client
        config = open_api_models.Config(
            access_key_id='your access_key_id',
            access_key_secret='your access_key_secret',
            endpoint="cloudauth-intl.cn-hongkong.aliyuncs.com"
        )
        client = CloudauthClient(config)

        # Build request
        request = cloudauth_models.FaceCompareRequest(
            merchant_biz_id="e0c34a77f5ac40a5aa5e6ed20c35****",
            # set sourceFacePicture or sourceFacePictureUrl
            source_face_picture="base64 string",
            source_face_picture_url="https://***",
            # set targetFacePicture or targetFacePictureUrl
            target_face_picture="base64 string",
            target_face_picture_url="https://***"
        )

        # Invoke API
        response = client.face_compare(request)

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


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