Compute Engine client libraries

The Compute Engine API is built on HTTP and JSON, so any standard HTTP client can send requests to it and parse the responses. However, instead of creating HTTP requests and parsing responses manually, you might want to use client libraries to do so.

Client libraries provide better language integration, improved security, and support for making calls that require user authorization. You can use the Compute Engine API through a number of Google-provided libraries or through third-party open source libraries that are known to work on Compute Engine.

Available libraries

Although you can use Cloud APIs by making direct HTTP requests to the server (or RPC calls where available), we provide different types of client libraries for Cloud APIs that makes them easier to access from your favorite languages.

For information on the different types of client libraries, see Client Libraries Explained.

Google API Client Libraries

The following Google API Client Libraries are available:

Library Language(s) Vendor Website Getting started on Compute Engine
Google API Go Client Library Go Google Website Documentation
Google API Java Client Library Java Google Website Documentation
Google API JavaScript Client Library JavaScript Google Website Documentation
Google API .NET Client Library .NET Google Website Documentation
Google API Node.js Client Library Node.js Google Website Documentation
Google API Objective-C Client Library Objective-C Google Website Documentation
Google API PHP Client Library PHP Google Website Documentation
Google API Python Client Library Python Google Website Documentation
Google API Ruby Client Library Ruby Google Website Documentation

Google Cloud Client Libraries

The following Google Cloud Client Libraries are available:

Library Language(s) Vendor Website Getting started on Compute Engine
Google Cloud Java Client Library Java Google Website Documentation
Google Cloud Node.js Client Library Node.js Google Website Documentation

The following Google Cloud Client Libraries are available in preview:

Library Language(s) Vendor Website Getting started on Compute Engine
Google Cloud Go Client Library Go Google Website Documentation
Google Cloud Java Client Library Java Google Website Documentation
Google Cloud .NET Client Library .NET Google Website Documentation
Google Cloud Node.js Client Library Node.js Google Website Documentation
Google Cloud PHP Client Library PHP Google Website Documentation
Google Cloud Python Client Library Python Google Website Documentation
Google Cloud Ruby Client Library Ruby Google Website Documentation

Community libraries

The following table contains a list of community libraries:

Library Language(s) Vendor Website Getting started on Compute Engine
libcloud Python Community Website Documentation
jclouds Java, Clojure Community Website Documentation
fog.io Ruby Community Website Documentation

Google API Go Client Library

This section contains information about getting started with the Compute Engine API using the Google APIs Go client library. In addition, you might be interested in the following documentation:

Downloading and installing the library

To install the library, run the following command:

go get google.golang.org/api/compute/v1

Using the library

Import the library in your code:

package main

  import (
      "google.golang.org/api/compute/v1"
  )

Google API Java Client Library

This page contains information about getting started with the Compute Engine API using the Google API Client Library for Java. In addition, you may be interested in the following documentation:

Sample

The compute-engine-cmdline-sample may help you get started using the client library.

Add Library to Your Project

Select your build environment (Maven or Gradle) from the following tabs:

Google API JavaScript Client Library

This section contains information about getting started with the Compute Engine API using the Google APIs JavaScript client library. In addition, you might be interested in the following documentation:

Using the API

To use the API, you must first load the library. In your code, add:

<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>

Google API .NET Client Library

This section contains information about getting started with the Compute Engine API using the Google API Client Library for .NET. In addition, you may be interested in the following documentation:

Downloading the library

Install the NuGet package: Google.Apis.

Google API Node.js Client Library

Read the Compute Engine Node.js getting started guide.

Google API Objective-C Client Library

This section contains information about getting started with the Compute Engine API using the Google APIs Objective-C client library. In addition, you might be interested in the following documentation:

Google API PHP Client Library

This section contains information about getting started with the Compute Engine API using the Google APIs PHP client library. In addition, you might be interested in the following documentation:

Downloading the library

The library can be installed by adding it as a dependency to your composer.json.

"require": {
  "google/apiclient": "1.0.*"
}

If you prefer, the library is available on GitHub and can be cloned into a local repository with the git clone method.

git clone https://github.com/google/google-api-php-client.git .

Using the library

The best way to define the location of library files is to add it to the path in the PHP.ini configuration file.

include_path = ".:/usr/local/lib/php:/path/to/google-api-php-client/src"

Alternatively, the same ini directive can be set dynamically in your code.

set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/google-api-php-client/src');

Google API Python Client Library

This page contains information about getting started with the Compute Engine API using the Google API Client Library for Python. In addition, you may be interested in the following documentation:

System requirements

Installing the client library

You can either use a package manager or download and install the Python client library manually:

Managed installation

Use pip or setuptools to manage your installation (you might need to run sudo first):

  • pip (preferred):
    $ pip install --upgrade google-api-python-client
  • Setuptools: Use the easy_install tool included in the setuptools package:
    $ easy_install --upgrade google-api-python-client

Manual installation

Download the latest client library for Python, unpack the code, and run python setup.py install

App Engine

Because the Python client libraries are not installed in the App Engine Python runtime environment, they must be vendored into your application just like third-party libraries.

Google API Ruby Client Library

This page contains information about getting started with the Compute Engine API using the Google API Client Library for Ruby. In addition, you may be interested in the following documentation:

Installing the google-api-client gem

If you haven't installed the Google API Client Library for Ruby before, open a terminal and install using RubyGems:

gem install google-api-client

If you already have the gem installed and would like to update to the latest version:

gem update -y google-api-client

Depending on your system, you may need to prepend these commands with sudo.

Google Cloud Java Client Library

Read the Compute Engine Java getting started guide.

For the current recommended version of this library, use a version earlier than 1.0.0. Versions 1.0.0 and later of this library are currently in preview and are backwards incompatible with earlier versions.

Google Cloud Node.js Client Library

Read the Compute Engine Node.js getting started guide.

For the current recommended version of this library, use a version earlier than 3.0.0. Versions 3.0.0 and later of this library are currently in preview and are backwards incompatible with earlier versions.

libcloud

libcloud is a Python library for interacting with multiple cloud service providers through a single unified API. This project supports a broad set of Compute Engine features including instances, disks, networks/firewalls, and load balancers.

jclouds

jclouds is an open source library that allows you to use Java and Clojure across multiple cloud providers. The jclouds cloud API has support for Compute Engine and allows users to manage resources such as VMs, disks, and networking. As of version 1.9, Compute Engine was promoted to the jclouds core.

fog.io

fog.io fog.io is an open source Ruby library that allows you to interact with multiple cloud services through one API. The fog.io cloud API supports instance operations such as create, destroy, and bootstrap. It also supports managing other resources such as disks, networks, and load balancers.