BigQuery Reservation API Client Libraries

This page shows how to get started with the Cloud Client Libraries for the BigQuery Reservation 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.Reservation.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-bigqueryreservation" % "2.19.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-reservation


For more information, see Using PHP on Google Cloud.

composer require google/cloud-bigquery-reservation


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

pip install --upgrade google-cloud-bigquery-reservation


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

gem install google-cloud-bigquery-reservation

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 Reservation API by enumerating resources, namely reservations and capacity commitments.


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

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

// The bigquery_reservation_quickstart application demonstrates usage of the
// BigQuery reservation API by enumerating some of the resources that can be
// associated with a cloud project.
package main

import (

	reservation ""
	reservationpb ""

func main() {

	// Define two command line flags for controlling the behavior of this quickstart.
	var (
		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()
	bqResClient, err := reservation.NewClient(ctx)
	if err != nil {
		log.Fatalf("NewClient: %v", err)
	defer bqResClient.Close()

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

	s, err = reportReservations(ctx, bqResClient, *projectID, *location)
	if err != nil {
		log.Fatalf("printReservations: %v", err)

// printCapacityCommitments iterates through the capacity commitments and returns a byte buffer with details.
func reportCapacityCommitments(ctx context.Context, client *reservation.Client, projectID, location string) (string, error) {
	var buf bytes.Buffer
	fmt.Fprintf(&buf, "Capacity commitments in project %s in location %s:\n", projectID, location)

	req := &reservationpb.ListCapacityCommitmentsRequest{
		Parent: fmt.Sprintf("projects/%s/locatio