Client

Parent client for calling the Google Cloud Bigtable API.

This is the base from which all interactions with the API occur.

In the hierarchy of API concepts

google.cloud.bigtable.client.ADMIN_SCOPE( = 'https://www.googleapis.com/auth/bigtable.admin )

Scope for interacting with the Cluster Admin and Table Admin APIs.

class google.cloud.bigtable.client.Client(project=None, credentials=None, read_only=False, admin=False, client_info=None, client_options=None, admin_client_options=None, channel=None)

Bases:google.cloud.client.ClientWithProject

Client for interacting with Google Cloud Bigtable API.

NOTE: Since the Cloud Bigtable API requires the gRPC transport, no_http argument is accepted by this class.

  • Parameters

    • project (str orunicode) – (Optional) The ID of the project which owns theinstances, tables and data. If not provided, willattempt to determine from the environment.

    • credentials (Credentials) – (Optional) The OAuth2 Credentials to use for thisclient. If not passed, falls back to the defaultinferred from the environment.

    • read_only (bool) – (Optional) Boolean indicating if the data scope should befor reading only (or for writing as well). Defaults toFalse.

    • admin (bool) – (Optional) Boolean indicating if the client will be used tointeract with the Instance Admin or Table Admin APIs. Thisrequires theADMIN_SCOPE. Defaults toFalse.

    • client_info – The client info used to send a user-agent string along with APIrequests. IfNone, then default info will be used. Generally,you only need to set this if you’re developing your own libraryor partner tool.

    • client_options (ClientOptionsordict) – (Optional) Client options used to set user optionson the client. API Endpoint should be set through client_options.

    • admin_client_options (ClientOptions ordict) – (Optional) Client options used to set useroptions on the client. API Endpoint for admin operations should be setthrough admin_client_options.

    • (grpc.Channel) (channel) – (Optional) DEPRECATED:AChannel instance through which to make calls.This argument is mutually exclusive withcredentials;providing both will raise an exception. No longer used.

  • Type

    client_info:google.api_core.gapic_v1.client_info.ClientInfo

  • Raises

    ValueError if bothread_only andadmin areTrue

instance(instance_id, display_name=None, instance_type=None, labels=None)

Factory to create a instance associated with this client.

For example:

from google.cloud.bigtable importClientfrom google.cloud.bigtable import enumsmy_instance_id = "inst-my-" + UNIQUE_SUFFIXmy_cluster_id = "clus-my-" + UNIQUE_SUFFIXlocation_id = "us-central1-f"serve_nodes = 1storage_type = enums.StorageType.SSDproduction = enums.Instance.Type.PRODUCTIONlabels = {"prod-label": "prod-label"}client = Client(admin=True)instance =client.instance(my_instance_id, instance_type=production, labels=labels)cluster = instance.cluster(    my_cluster_id,    location_id=location_id,    serve_nodes=serve_nodes,    default_storage_type=storage_type,)operation = instance.create(clusters=[cluster])# We want to make sure the operation completes.operation.result(timeout=100)
  • Parameters

    • instance_id (str) – The ID of the instance.

    • display_name (str) – (Optional) The display name for the instance inthe Cloud Console UI. (Must be between 4 and 30characters.) If this value is not set in theconstructor, will fall back to the instance ID.

    • instance_type (int) – (Optional) The type of the instance.Possible values are representedby the following constants:google.cloud.bigtable.instance.InstanceType.PRODUCTION.google.cloud.bigtable.instance.InstanceType.DEVELOPMENT,Defaults togoogle.cloud.bigtable.instance.InstanceType.UNSPECIFIED.

    • labels (dict) – (Optional) Labels are a flexible and lightweightmechanism for organizing cloud resources into groupsthat reflect a customer’s organizational needs anddeployment strategies. They can be used to filterresources and aggregate metrics. Label keys must bebetween 1 and 63 characters long. Maximum 64 labels canbe associated with a given resource. Label values mustbe between 0 and 63 characters long. Keys and valuesmust both be under 128 bytes.

  • Return type

    Instance

  • Returns

    an instance owned by this client.

property instance_admin_client()

Getter for the gRPC stub used for the Table Admin API.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)instance_admin_client =client.instance_admin_client
  • Return type

    bigtable_admin_pb2.BigtableInstanceAdmin

  • Returns

    A BigtableInstanceAdmin instance.

  • Raises

    ValueError if the current client is not an admin client or if it has not beenstart()-ed.

list_clusters()

List the clusters in the project.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)(clusters_list, failed_locations_list) =client.list_clusters()
  • Return type

    tuple

  • Returns

    (clusters, failed_locations), where ‘clusters’ is list ofgoogle.cloud.bigtable.instance.Cluster, and ‘failed_locations’ is a list of strings representing locations which could not be resolved.

list_instances()

List instances owned by the project.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)(instances_list, failed_locations_list) =client.list_instances()

property project_path()

Project name to be used with Instance Admin API.

NOTE: This property will not change ifproject does not, but thereturn value is not cached.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)project_path =client.project_path

The project name is of the form

"projects/{project}"

  • Return type

    str

  • Returns

    Return a fully-qualified project string.

property table_admin_client()

Getter for the gRPC stub used for the Table Admin API.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)table_admin_client =client.table_admin_client
  • Return type

    bigtable_admin_pb2.BigtableTableAdmin

  • Returns

    A BigtableTableAdmin instance.

  • Raises

    ValueError if the current client is not an admin client or if it has not beenstart()-ed.

property table_data_client()

Getter for the gRPC stub used for the Table Admin API.

For example:

from google.cloud.bigtable importClientclient = Client(admin=True)table_data_client =client.table_data_client
  • Return type

    bigtable_v2.BigtableClient

  • Returns

    A BigtableClient object.

google.cloud.bigtable.client.DATA_SCOPE( = 'https://www.googleapis.com/auth/bigtable.data )

Scope for reading and writing table data.

google.cloud.bigtable.client.READ_ONLY_SCOPE( = 'https://www.googleapis.com/auth/bigtable.data.readonly )

Scope for reading table data.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-09 UTC.