Google Chat API client libraries

Client libraries optimize the developer experience for calling the Google Chat API by reducing the boilerplate code you have to write. This guide introduces the client libraries and explains how to install them.

Chat API has gRPC and REST interfaces, and client libraries that support both. Cloud Client Libraries support gRPC and REST interfaces, Google API Client Libraries only support the REST interface, but you can use both client libraries in the same project. Optionally, if the provided client libraries don't meet your needs, you can write your own client libraries that use the gRPC or REST interface.

To learn more about the types of client libraries Google supports, see Client libraries explained.

Install Cloud Client Libraries (recommended)

Cloud Client Libraries are the latest and recommended client libraries for calling Chat API. Cloud Client Libraries support both gRPC and REST interfaces.

Chat API provides Cloud Client Libraries for the following languages. Select the language that you want to use:

Node.js

To install the client library:

npm install @google-apps/chat

Learn more:

Python

To install the client library:

python -m venv <your-env>
source <your-env>/bin/activate
pip install google-apps-chat

Learn more:

Java

Select your build environment from the following tabs. Whichever you use, remember to update the version to the most recent release available on GitHub.

Maven with BOM

If you're using Maven with BOM, add this to your pom.xml file:

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>libraries-bom</artifactId>
        <version>26.42.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-chat</artifactId>
    </dependency>
<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-chat</artifactId>
  <version>0.10.0</version>
</dependency>

Maven without BOM

If you're using Maven without BOM, add this to your dependencies:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-chat</artifactId>
  <version>0.9.0</version>
</dependency>

Gradle

If you're using Gradle without BOM, add this to your dependencies:

implementation 'com.google.cloud:google-cloud-chat:0.10.0'

SBT

If you are using SBT, add this to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-chat" % "0.10.0"

Learn more:

Go

Import the Go packages for Google Cloud services.

import "cloud.google.com/go"

To install the package on your system:

  1. Change to your project directory: cd /my/cloud/project.
  2. Get the package you want to use:
go get cloud.google.com/go/chat

Learn more:

Ruby

To install the client library:

gem install google-apps-chat

Learn more:

PHP

To install the client library:

  1. If necessary, install the dependency manager Composer.
  2. From your command line interface, run:
composer require google/apps-chat

Learn more:

.NET

To install the client library:

Install the Google.Apps.Chat.V1 package from NuGet. Add it to your project in the normal way (for example by right-clicking on the project in Visual Studio and choosing "Manage NuGet Packages..."). Make sure you enable pre-release packages (for example, in the Visual Studio NuGet user interface, check the "Include prerelease" box).

To install the NuGet package, visit Google.Apis at NuGet.org.

Learn more:

Install Google API Client Libraries

An alternative to Cloud Client Libraries, Google API Client Libraries provide programmatic access to Chat API using REST resources and methods. You might prefer to use Google API Client Libraries if you use a language that does not have a Cloud Client Library, or if you are extending a project that already uses them.

Chat API provides Google API Client Libraries for the following languages. Select the language that you want to use:

Go

Get the latest Google Chat API client library for Go (alpha). Read the client library's developer's guide.

Java

This page contains information about getting started with the Google Chat API by using the Google API Client Library for Java. For more information, see the following documentation:

Add the client library to your project

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

JavaScript

Read the client library's developer's guide.

.NET

This page contains information about getting started with the Google Chat API by using the Google API Client Library for .NET. For more information, see the following documentation:

Downloading the library

Install the NuGet package: Google.Apis.

Node.js

Get the latest Google Chat API client library for Node.js. Read the client library's developer's guide.

Obj-C

Get the latest Google Chat API client library for Objective-C. Read the client library's developer's guide.

PHP

Get the latest Google Chat API client library for PHP. Read the client library's developer's guide.

Python

This page contains information about getting started with the Google Chat API by using the Google API Client Library for Python. For more information, see the following documentation:

System requirements

Install the client library

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

Managed install

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:
    easy_install --upgrade google-api-python-client

Manual install

  1. Download the latest client library for Python.
  2. Unpack the code.
  3. Install:
    python setup.py install

App Engine

Because the Python client libraries aren't installed in the App Engine Python runtime environment, you must copy them into your application just like third-party libraries.

Ruby

This page contains information about getting started with the Google Chat API by using the Google API Client Library for Ruby. For more information, see the following documentation:

Install the google-api-client gem

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

If you haven't installed the Google API Client Library for Ruby before, install by using RubyGems:

gem install google-api-client

If you already have the gem installed, update to the latest version:

gem update -y google-api-client

Get started with the Google API Client Library for Ruby

To learn how to make your first request, see the Get started guide.

Apps Script and client libraries

The recommended way for most developers to call the Google Chat API is with our officially supported Cloud Client Libraries for your preferred language, like Python, Java, or Node.js.

If you're coding with Google Apps Script, use the Advanced Chat service instead of installing a client library.

Authentication

Calling the Chat API requires authentication. Each Chat API method requires either user authentication (to perform actions or access data on behalf of a user) or app authentication (to perform actions or access data as a Chat app). Some methods support both user authentication and app authentication.

To learn more about authentication in Chat, see Authentication overview.