All Products
Document Center

ApsaraDB for HBase:Example of calling an API operation

Last Updated:Aug 24, 2023

This topic describes how to call the DescribeInstances operation by using ApsaraDB for HBase SDK for Python to query a list of ApsaraDB for HBase clusters and their basic information.

View the API documentation

Before you call an operation, we recommend that you read the API documentation and get yourself familiar with the parameters and permissions that are required to call the operation. For more information, see List of operations by function.

Create a RAM user and grant permissions to the RAM user

If you have created a Resource Access Management (RAM) user and granted permissions to the RAM user, skip this step.

  1. Create a RAM user.

    1. Log on to the RAM console. In the left-side navigation pane, choose Identities > Users. On the Users page, click Create User.

    2. On the Create User page, set Logon Name to hbase-openapi-operator and select OpenAPI Access for Access Mode.

    3. Click OK. The RAM user is created. The system automatically generates an AccessKey ID and an AccessKey secret for the RAM user. Record the AccessKey ID and AccessKey secret.

  2. Grant permissions to the RAM user.

    1. Go back to the Users page, find the RAM user that you created, and then click Add Permissions in the Actions column.

    2. In the Add Permissions panel, search for AliyunHBase in the text box and select the AliyunHBaseReadOnlyAccess policy.


      The AliyunHBaseReadOnlyAccess policy has permissions to query ApsaraDB for HBase clusters. You can also select the AliyunHBaseFullAccess policy or define a policy. The AliyunHBaseFullAccess policy has all permissions on ApsaraDB for HBase clusters, including querying and modifying ApsaraDB for HBase clusters. For more information, see Customize a RAM policy.

    3. Click OK.

Call an operation

This section describes how to call the DescribeInstances operation by using ApsaraDB for HBase SDK for Python. For more information about using ApsaraDB for HBase SDKs for other programming languages, see ApsaraDB for HBase SDKs.

Prepare a Python environment

Download and install Python 3. If you have installed Python, run the python --version command to query the Python version.

Set environment variables

This section describes how to set the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables in your operating system.

  • If you use a Linux or macOS operating system, replace <access_key_id> and <access_key_secret> with the AccessKey ID and AccessKey secret of the RAM user, and then run the following commands:

    export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>
    export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>
  • If you use a Windows operating system, create an environment variable file, add the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables to the environment variable file, and then write the AccessKey ID and AccessKey secret of the RAM user. Restart the Windows system.

Install dependencies

Run the following commands on your device to install environment dependencies:

pip install alibabacloud_credentials
pip install alibabacloud_hbase20190101
pip install alibabacloud_tea_console

Download sample code

  1. Click DescribeInstances to open the DescribeInstances operation page on the OpenAPI Portal.

  2. On the Parameters tab, set the required parameters. For this example, enter cn-hangzhou for RegionId.

  3. On the SDK Sample Code tab, select Python for Languages and click Download Project to download the sample code package.

  4. Decompress the sample code package on your device and go to the alibabacloud_sample directory.

Run the sample code

Run the following command:


Sample result:

] {
    "headers": {
        "date": "Mon, 24 Jul 2023 09:56:30 GMT",
        "content-type": "application/json;charset=utf-8",
        "content-length": "943",
        "connection": "keep-alive",
        "keep-alive": "timeout=25",
        "access-control-allow-origin": "*",
        "access-control-expose-headers": "*",
        "x-acs-request-id": "C20BAA8E-C543-58F1-A611-9C812336****",
        "x-acs-trace-id": "63ca81587ddddeb0d47443462b3d****",
        "etag": "919xrdSHGE5LzH4To3ra****"
    "body": {
            "Instance": [
                    "BackupStatus": "open",
                    "ClusterId": "ld-bp1st3v9780tk****",
                    "ClusterName": "Test",
                    "ClusterType": "cluster",
                    "ColdStorageStatus": "open",
                    "CoreDiskCount": 4,
                    "CoreDiskSize": 100,
                    "CoreDiskType": "cloud_ssd",
                    "CoreInstanceType": "hbase.sn2.large",
                    "CoreNodeCount": 4,
                    "CreatedTime": "2023-07-24T17:44:54",
                    "CreatedTimeUTC": "2023-07-24T09:44:54Z",
                    "Engine": "hbaseue",
                    "InstanceId": "ld-bp1st3v9780tk****",
                    "InstanceName": "Test",
                    "IsDeletionProtection": false,
                    "IsHa": true,
                    "MajorVersion": "2.0",
                    "MasterDiskSize": 0,
                    "MasterDiskType": "",
                    "MasterInstanceType": "hbase.sn1.large",
                    "MasterNodeCount": 2,
                    "ModuleId": 0,
                    "NetworkType": "VPC",
                    "PayType": "Postpaid",
                    "RegionId": "cn-hangzhou",
                    "ResourceGroupId": "rg-acfmz7u4zzr****",
                    "Status": "ACTIVATION",
                    "Tags": {
                        "Tag": []
                "VpcId": "vpc-bp16crlc5o2dmwi8p****",
                "VswitchId": "vsw-bp1sueafuqh4ly8ae****",
                "ZoneId": "cn-hangzhou-f"
        "PageNumber": 1,
        "PageSize": 10,
        "RequestId": "C20BAA8E-C543-58F1-A611-9C812336****",
        "TotalCount": 1