BigQuery Connection API Client Libraries

This page shows how to get started with the Cloud Client Libraries for the BigQuery Connection API. Read more about the client libraries for Cloud APIs, including the older Google API Client Libraries, in Client Libraries Explained.

Install the client library


For more information, see Setting Up a C# Development Environment.

Install-Package Google.Cloud.BigQuery.Connection.V1 -Pre


For more information, see Setting Up a Go Development Environment.

go get


For more information, see Setting Up a Java Development Environment.

If you are using Maven, add the following to your pom.xml file. For more information about BOMs, see The Google Cloud Platform Libraries BOM.


If you are using Gradle, add the following to your dependencies:

implementation ''

If you are using sbt, add the following to your dependencies:

libraryDependencies += "" % "google-cloud-bigqueryconnection" % "2.15.0"

If you're using Visual Studio Code, IntelliJ, or Eclipse, you can add client libraries to your project using the following IDE plugins:

The plugins provide additional functionality, such as key management for service accounts. Refer to each plugin's documentation for details.


For more information, see Setting Up a Node.js Development Environment.

npm install @google-cloud/bigquery-connection


For more information, see Using PHP on Google Cloud.

composer require google/cloud-bigquery-connection


For more information, see Setting Up a Python Development Environment.

pip install --upgrade google-cloud-bigquery-connection


For more information, see Setting Up a Ruby Development Environment.

gem install google-cloud-bigquery-connection

Set up authentication

When you use client libraries, you use Application Default Credentials (ADC) to authenticate. For information about setting up ADC, see Provide credentials for Application Default Credentials. For information about using ADC with client libraries, see Authenticate using client libraries.

Use the client library

The following example demonstrates some basic interactions with the BigQuery Connection API.


To use this sample, prepare your machine for Go development, and complete the BigQuery Connection API quickstart. For more information, see the BigQuery Connection API Go API reference documentation.

To authenticate to BigQuery Connection API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

// The bigquery_connection_quickstart application demonstrates basic usage of the
// BigQuery connection API.
package main

import (

	connection ""
	connectionpb ""

func main() {

	// Define two command line flags for controlling the behavior of this quickstart.
	projectID := flag.String("project_id", "", "Cloud Project ID, used for session creation.")
	location := flag.String("location", "US", "BigQuery location used for interactions.")

	// Parse flags and do some minimal validation.
	if *projectID == "" {
		log.Fatal("empty --project_id specified, please provide a valid project ID")
	if *location == "" {
		log.Fatal("empty --location specified, please provide a valid location")

	ctx := context.Background()
	connClient, err := connection.NewClient(ctx)
	if err != nil {
		log.Fatalf("NewClient: %v", err)
	defer connClient.Close()

	s, err := reportConnections(ctx, connClient, *projectID, *location)
	if err != nil {
		log.Fatalf("printCapacityCommitments: %v", err)

// reportConnections gathers basic information about existing connections in a given project and location.
func reportConnections(ctx context.Context, client *connection.Client, projectID, location string) (string, error) {
	var buf bytes.Buffer
	fmt.Fprintf(&buf, "Current connections defined in project %s in location %s:\n", projectID, location)

	req := &connectionpb.ListConnectionsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	totalConnections := 0
	it := client.ListConnections(ctx, req)
	for {
		conn, err := it.Next()
		if err == iterator.Done {
		if err != nil {
			return "", err
		fmt.Fprintf(&buf, "\tConnection %s was created %s\n", conn.GetName(), unixMillisToTime(conn.GetCreationTime()).Format(time.RFC822Z))