Google Chat API 概览
本页简要介绍了如何使用 Google Chat API 及其参考文档。
Google Chat API 具有 gRPC 和 REST 接口,以及同时支持这两种接口的客户端库。或者,如果提供的客户端库无法满足您的需求,您可以自行编写使用 gRPC 或 REST 接口的客户端库。
客户端库
对于大多数开发者来说,调用 Google Chat API 的推荐方式是使用我们官方支持的Cloud 客户端库(适用于您偏好的语言,例如 Python、Java 或 Node.js)。
如果您使用 Google Apps 脚本进行编码,请使用高级 Chat 服务,而不是安装客户端库。
类型、方法和字段名称
根据您使用的是客户端库、gRPC 还是 REST,Google Chat API 的类型、方法和字段名称略有不同:
- Cloud 客户端库按 gRPC 服务及其方法进行安排。Google API 客户端库以服务形式排列,其中包含与 REST 资源对应的对象或类,这些对象或类还包含相应的方法。
- gRPC 按服务及其方法进行安排。
- REST 按资源层次结构及其方法进行安排。
- gRPC 字段名称使用蛇形命名法。
- REST 字段名称使用驼峰式命名法,但 API 服务将接受驼峰式命名法或蛇形命名法。
- 客户端库字段名称使用词首字母大写形式、驼峰式命名法或蛇形命名法,取决于哪种名称对于语言是惯用的。
Protocol Buffers
无论您使用的是客户端库、REST 还是 gRPC,底层服务都是使用协议缓冲区定义的。具体来说,该服务使用 proto3。
调用 API 时,某些请求或响应字段可能需要对协议缓冲区知名类型有基本的了解。
此外,在调用 REST API 时,协议缓冲区的默认值行为可能会导致 JSON 响应中缺少字段。这些字段已设置为默认值,因此未包含在响应中。
API 版本
以下 API 版本可供使用:
开发者预览版
在文档中,您可能会看到仅通过开发者预览计划提供的 API 方法或字段。如需测试和预览最新预览版功能并提供反馈,请加入开发者预览版计划。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["This page offers guidance on utilizing the Google Chat API and navigating its reference documentation, including gRPC and REST interfaces."],["Developers are encouraged to use the provided client libraries for Python, Java, Node.js, or the Advanced Chat service for Google Apps Script."],["Type, method, and field names may vary slightly depending on whether you are using client libraries, gRPC, or REST, with details provided on their respective conventions."],["The Google Chat API is built upon protocol buffers, specifically proto3, which may require a basic understanding for certain request and response fields."],["Stable API version v1 is currently available, with access to developer preview features obtainable through the Developer Preview Program."]]],["The Google Chat API offers gRPC and REST interfaces, with corresponding client libraries or the option to create custom ones. Developers can use Cloud Client Libraries, or the Advanced Chat service with Google Apps Script. Type, method, and field names vary across libraries, gRPC, and REST. The API relies on protocol buffers (proto3), which can impact JSON responses due to default value behavior. The current stable version is v1, with a Developer Preview program for testing new features.\n"]]