Google Chat API client libraries (original) (raw)
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 hasgRPCandRESTinterfaces, 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, seeClient libraries explained.
Install Cloud Client Libraries (recommended)
Cloud Client Librariesare 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/chatLearn 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 withBOM, 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 withoutBOM, 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 withoutBOM, 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:
- Change to your project directory:
cd /my/cloud/project. - Get the package you want to use:
go get cloud.google.com/go/chatLearn more:
Ruby
To install the client library:
gem install google-apps-chatLearn more:
PHP
To install the client library:
- If necessary, install the dependency managerComposer.
- From your command line interface, run:
composer require google/apps-chatLearn 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, visitGoogle.Apis at NuGet.org.
Learn more:
An alternative to Cloud Client Libraries,Google API Client Librariesprovide 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:
Apps Script and client libraries
The recommended way for most developers to call the Google Chat API is with our officially supportedCloud Client Librariesfor your preferred language, like Python, Java, or Node.js.
If you're coding with Google Apps Script, use theAdvanced Chat serviceinstead of installing a client library.
Authentication
Calling the Chat API requires authentication. Each Chat API method requires eitheruser authentication(to perform actions or access data on behalf of a user) orapp 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, seeAuthentication overview.