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-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eThis page offers guidance on utilizing the Google Chat API and navigating its reference documentation, including gRPC and REST interfaces.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers are encouraged to use the provided client libraries for Python, Java, Node.js, or the Advanced Chat service for Google Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eType, 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.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Chat API is built upon protocol buffers, specifically proto3, which may require a basic understanding for certain request and response fields.\u003c/p\u003e\n"],["\u003cp\u003eStable API version v1 is currently available, with access to developer preview features obtainable through the Developer Preview Program.\u003c/p\u003e\n"]]],["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"],null,["# Google Chat API overview\n\nThis page provides an overview of how to use Google Chat API and its reference\ndocumentation.\n\nGoogle Chat API has both [gRPC](/workspace/chat/api/reference/rpc) and\n[REST](/workspace/chat/api/reference/rest) interfaces, and\n[client libraries](/workspace/chat/libraries) that support both. Optionally, if\nthe provided client libraries don't meet your needs, you can write your own\nclient libraries that use the gRPC or REST interface.\n\nClient libraries\n----------------\n\nThe recommended way for most developers to call the Google Chat API\nis with our officially supported\n[Cloud Client Libraries](/workspace/chat/libraries)\nfor your preferred language, like Python, Java, or Node.js.\n\nIf you're coding with Google Apps Script, use the\n[Advanced Chat service](/apps-script/advanced/chat)\ninstead of installing a client library.\n\nType, method, and field names\n-----------------------------\n\nDepending on whether you're using client libraries, gRPC, or REST, the type,\nmethod, and field names for the Google Chat API vary somewhat:\n\n- Cloud Client Libraries are arranged by gRPC services and their methods. Google API Client Libraries are arranged as services that contain objects or classes that correspond with REST resources, which also contain corresponding methods.\n- gRPC is arranged by services and their methods.\n- REST is arranged by resource hierarchies and their methods.\n- gRPC field names use snake case.\n- REST field names use camel case, though the API service will accept either camel case or snake case.\n- Client library field names use either title case, camel case or snake case, depending on which name is idiomatic for the language.\n\nProtocol buffers\n----------------\n\nWhether you are using client libraries, REST, or gRPC, the underlying service is\ndefined using [protocol buffers](/protocol-buffers). In particular, the service\nuses [proto3](/protocol-buffers/docs/proto3).\n\nWhen calling the API, some request or response fields can require a basic\nunderstanding of\n[protocol buffer well-known types](/protocol-buffers/docs/reference/google.protobuf).\n\nIn addition, when calling the REST API, the\n[default value](/protocol-buffers/docs/proto3#default) behavior for protocol\nbuffers may result in missing fields in a JSON response. These fields are\nset to the default value, so they are not included in the response.\n\nAPI versions\n------------\n\nThe following API versions are available:\n\n- **v1**: Stable.\n\nDeveloper Preview\n-----------------\n\nIn the documentation, you might see API methods or fields that are only\navailable through the Developer Preview Program. To test and preview and offer\nfeedback on the latest preview features, join the\n[Developer Preview Program](/workspace/preview).\n\nRelated topics\n--------------\n\n- [Call the Google Chat API](/workspace/chat/api-overview)"]]