This page shows how to get started with the Cloud Client Libraries for the Compute Engine API. Read more about the client libraries for Cloud APIs, including the older Google API Client Libraries, in Client Libraries Explained.
To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:
Install the client library
C#
For more information, see Setting Up a C# Development Environment.
Install the
Google.Cloud.Compute.V1
package from NuGet.
Go
For more information, see Setting Up a Go Development Environment.
go get cloud.google.com/go/compute/apiv1
Java
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:
If you are using sbt, add the following to your dependencies:
The older version of the Cloud Client Libraries for Java for Compute Engine is available as version 0.120.x or earlier in the Maven artifact. Versions 0.120.x and earlier of this library are forward-incompatible with later versions.
Node.js
For more information, see Setting Up a Node.js Development Environment.
npm install @google-cloud/compute
The older version of the Cloud Client Libraries for Node.js for Compute Engine is available as version 2.5.x or earlier in the npm package. Versions 2.5.x and earlier of this library are forward-incompatible with later versions.
PHP
For more information, see Using PHP on Google Cloud.
composer require google/cloud-compute
Python
For more information, see Setting Up a Python Development Environment.
pip install --upgrade google-cloud-compute
Ruby
For more information, see Setting Up a Ruby Development Environment.
gem install google-cloud-compute-v1
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 shows how to use the client library to list instances in a particular zone. For more examples, see Using client libraries.
C#
For more information, see the Compute Engine C# API reference documentation.
Go
For more information, see the Compute Engine Go API reference documentation.
Java
For more information, see the Compute Engine Java API reference documentation.
Node.js
For more information, see the Compute Engine Node.js API reference documentation.
PHP
For more information, see the Compute Engine PHP API reference documentation.
Python
For more information, see the Compute Engine Python API reference documentation.
Ruby
For more information, see the Compute Engine Ruby API reference documentation.
Additional resources
C#
Go
Java
Node.js
PHP
Python
Ruby
Older client libraries
Cloud Client Libraries use our latest client library model and are the recommended option for accessing Cloud APIs programmatically.
For cases where you can't use Cloud Client Libraries, the following Google API Client Libraries are available:
Third-party Compute Engine API client libraries
libcloud
libcloud is a Python library used for interacting with multiple cloud service providers through a single unified API.
The Apache libcloud API project has received support and updates for Compute Engine since July 2013. It supports a broad set of Compute Engine features including instances, disks, networks, and load balancers. The getting started demo provides a code example of how to use libcloud and Compute Engine together.
jclouds
jclouds is an open source library that allows you to use Java and Clojure across multiple Cloud providers.
The jclouds cloud API supports Compute Engine and lets you manage resources such as virtual machines, disks, and networks. As of version 1.9, Compute Engine was promoted to the jclouds core.
fog.io
fog.io is an open source Ruby library that lets you interact with multiple cloud services through one API.
The fog.io cloud API has had support for Compute Engine since version 1.11.0 in May 2013. It supports instance operations such as create and delete, along with management operations for other resources like disks, networks, and load balancers.