All Products
Search
Document Center

ID Verification:Call examples for SDK for Python

Last Updated:Aug 30, 2024

This topic provides an example on how to call server-side-only API operations of ID Verification - KYC SDK for Python. KYC is short for Know Your Customer.

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 SDK for Python, see 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(
            product_code="FACE_LIVENESS_MIN",
            merchant_biz_id="***",
            # set sourceFacePicture or sourceFacePictureUrl
            source_face_picture="****",
            source_face_picture_url="****",
            # set targetFacePicture or targetFacePictureUrl
            target_face_picture="****",
            target_face_picture_url="****"
        )

        # Invoke API
        response = client.faceCompare(request)

        # Get result
        print(response.status_code)
        print(response.body.request_id)
        print(response.body.result.transaction_id)
        print(response.body.result.passed)
        print(response.body.result.sub_code)
      
if __name__ == '__main__':
    Initialize.main()