Client libraries explained

Client libraries make it easier to access Google Cloud APIs from a supported language. While you can use Google Cloud APIs directly by making raw requests to the server, client libraries provide simplifications that significantly reduce the amount of code you need to write.

This document explains the different types of client libraries that Google provides for Cloud APIs. You can also find out more about the available libraries for your product or language of choice in the product or language's documentation.

Cloud Client Libraries

Cloud Client Libraries are the recommended option for accessing Cloud APIs programmatically, where available. Cloud Client Libraries use the latest client library model and:

  • Provide idiomatic code in each language to make Cloud APIs simple and intuitive to use.
  • Provide a consistent style across client libraries to simplify working with multiple Cloud services.
  • Handle all the low-level details of communication with the server, including authenticating with Google.
  • Can be installed using familiar package management tools such as npm and pip.
  • In some cases, give you performance benefits by using gRPC. For more information, see the gRPC APIs.

You can find installation instructions and reference material for the Cloud Client Library on the Client Libraries page for the Cloud API's you're using. You can find links to get started with the Cloud Client Libraries and their reference documentation on the Cloud Client Libraries page.

Try it for yourself

If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.

Get started for free

Google API Client Libraries

A few Google Cloud APIs don't have Cloud Client Libraries available in all languages. If you want to use one of these APIs and there is no Cloud Client Library for your preferred language, you can still use the previous style of client library, called Google API Client Libraries. You might also use these libraries if you're upgrading a project that already uses them. These libraries:

  • Provide access to the API's REST interface only; gRPC is not supported.
  • Have autogenerated interface code that might not be as idiomatic as the Cloud Client Libraries.
  • Handle all the low-level details of communication with the server, including authenticating with Google.
  • Can be installed using familiar package management tools such as npm and pip.

These libraries are linked on the Client Libraries page for the relevant Cloud APIs.

Using the Firebase mobile platform

Firebase is the Google-wide solution for building applications on mobile devices. It offers an SDK with client code that lets you access mobile-relevant Cloud APIs from iOS, Android, and Web apps. For information on the supported Cloud APIs and how to get started with Firebase, see the Firebase documentation.

Using your own client code

If you're an experienced developer and Google's client libraries don't meet your specific needs, you can write your own custom code to access the service's lower-level service APIs directly.

REST/HTTP APIs

All Cloud APIs expose a simple traditional JSON/REST interface. If you need to write your own custom code to directly access the REST API using a third-party HTTP client library, you can find out more about how Cloud APIs work with different HTTP versions and implementations in the HTTP Guidelines.

gRPC APIs

gRPC is a language-neutral, platform-neutral, open source, remote procedure call (RPC) system initially developed at Google. You can find out about it at grpc.io. gRPC-enabled Cloud APIs generally have both REST and RPC interfaces, so rather than just using JSON over HTTP to talk to the REST interface, gRPC-enabled API clients can also use protocol buffers and gRPC over HTTP2 to talk to the RPC interface. You can find out if an API is gRPC-enabled by checking its APIs and Reference section.

If a Cloud API is gRPC-enabled, you can generate your own gRPC client libraries for it in any gRPC-supported language. To do this, you'll need the API's protocol buffers service definition (typically available from the repository on GitHub). You can then follow the instructions for your preferred language on grpc.io to generate and use your client.

If you don't want to generate your own gRPC code, you can still benefit from gRPC: a growing number of Cloud Client Libraries for gRPC-enabled APIs use gRPC "under the hood" to communicate with Google's servers. This is significantly more efficient in terms of throughput and CPU usage — accessing an API using gRPC can increase throughput per CPU by as much as a factor of 10 compared to the JSON REST API. Google plans to upgrade as many Cloud Client Libraries as possible to gRPC; in the meantime, you'll still get all the other advantages of Google's client library code.

Other ways to access Cloud APIs

If you don't want to access an API programmatically, you can access some of the same functionality using the tools in Google Cloud CLI or using the Google Cloud console.