ApsaraDB for HBase Performance-enhanced Edition allows you to connect the database by using Thrift that supports multiple languages. ApsaraDB for HBase Performance-enhanced Edition supports all the languages that are supported by Thrift. The ApsaraDB for HBase Performance-enhanced Edition server supports Thrift version 0.12.0. Although Thrift is backward-compatible, we recommend that you download the version 0.12.0. Click here to download this version. Some languages provide certain methods to manage dependencies. You can install Thrift based on relevant syntax. For example, you can run the pip install thrift command if you use Python and run the import {"github.com/apache/thrift/lib/go/thrift"} command if you use Go.

ApsaraDB for HBase Performance-enhanced Edition uses Thrift 2 as interface definition language (IDL) file. You must download the Thrift 2 to generate the API for the specified language. Compared with Thrift 1, Thrift 2 provides clearer definitions for API operations. You can perform the operations in a similar way as you call Java API operations. The earlier versions of Thrift 2 are not widely used because they do not support some DDL operations such as creating and deleting tables. Now, the comprehensive Thrift 2 APIs definitions of have been provided by Alibaba Cloud and released to the community. For more information, see HBASE-21649. Thrift 2 provides more comprehensive and easy-to-use features than Thrift 1.


  1. Click here to download the Thrift installation package.
  2. Download The Thrift 2 definition file of ApsaraDB for HBase.
  3. Retrieve the public endpoint or VPC internal endpoint used to connect to the cluster. For more information, see Connect to a cluster. You can refer to 'The endpoint used by APIs for multiple languages' section of the topic.


The following sections describe how to get started with Thrift. For more information about how to use Thrift, see Apache Thrift Tutorial.

1. Generate the API definition file for the specified language.

Download the API definition file and use the following syntax to generate the corresponding API definition files.

 thrift --gen <language> Hbase.thrift


thrift --gen php Hbase.thrift
thrift --gen cpp Hbase.thrift
thrift --gen py Hbase.thrift

2. Initialize a client to access ApsaraDB for HBase Performance-enhanced Edition.

The Thrift server of ApsaraDB for HBase Performance-enhanced Edition uses HTTP in the transport layer. Therefore, the ThttpClient of Thrift is required when you initialize a client. The client initialization method varies based on the languages. When the Access Control List (ACL) is enabled, you must specify the username and password headers in the ThttpClient for authentication. The username and password are not required if ACL is disabled. Thrift allows you to call a function for a certain language to customize a header in ThttpClient. The following example shows how to initialize the client and set the connect string, the username, and password based on Python. For more information, see the Demos for multiple languages section in this topic.

# -*- coding: utf-8  -*-
# You can run the pip install thrift command to retrieve the following modules.
from thrift.protocol import TBinaryProtocol
from thrift.transport import THttpClient

# The following module is generated by the thrift --gen py hbase.thrift command.
from hbase import THBaseService
from hbase.ttypes import TColumnValue, TColumn, TTableName, TTableDescriptor, TColumnFamilyDescriptor, TNamespaceDescriptor, TGet, TPut, TScan

# Endpoint
url = "http://host:9190"
transport = THttpClient.THttpClient(url)
headers = {}
# Username
# Password
protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
client = THBaseService.Client(protocol)
# The operations, and finally closes the connection.

Demos for multiple languages

All demo code has been uploaded to GitHub. The code includes the Thrift definition files and dependencies that are supported by certain languages. You can download the code for a certain language from Github.











More languages

For more information, see Apache Thrift Tutorial.