Google Chat API 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面概略說明如何使用 Google Chat API 和參考文件。
Google Chat API 具有 gRPC 和 REST 介面,以及同時支援這兩種介面的用戶端程式庫。如果提供的用戶端程式庫無法滿足需求,您也可以自行編寫使用 gRPC 或 REST 介面的用戶端程式庫。
用戶端程式庫
對大多數開發人員而言,呼叫 Google Chat API 的建議方式是使用我們正式支援的Cloud 用戶端程式庫,以您偏好的語言 (例如 Python、Java 或 Node.js) 進行呼叫。
如果您使用 Google Apps Script 進行編碼,請改用進階 Chat 服務,不必安裝用戶端程式庫。
類型、方法和欄位名稱
視您使用用戶端程式庫、gRPC 或 REST 而定,Google Chat API 的型別、方法和欄位名稱會略有不同:
- Cloud 用戶端程式庫是依據 gRPC 服務及其方法排列。Google API 用戶端程式庫會以服務的形式排列,其中包含與 REST 資源對應的物件或類別,以及對應的方法。
- gRPC 是依服務及其方法排列。
- REST API 會依資源階層及其方法排列。
- gRPC 欄位名稱使用蛇形命名法。
- REST 欄位名稱使用駝峰式大小寫,但 API 服務會接受駝峰式大小寫或蛇形命名法。
- 視語言的慣例而定,用戶端程式庫欄位名稱會使用首字大寫、駝峰式大小寫或蛇形命名法。
通訊協定緩衝區
無論您使用用戶端程式庫、REST 或 gRPC,基礎服務都是使用通訊協定緩衝區定義。具體來說,這項服務使用 proto3。
呼叫 API 時,部分要求或回應欄位可能需要具備通訊協定緩衝區的知名型別基本知識。
此外,呼叫 REST API 時,通訊協定緩衝區的預設值行為可能會導致 JSON 回應缺少欄位。這些欄位已設為預設值,因此不會納入回應。
API 版本
可用的 API 版本如下:
開發人員預覽版
在說明文件中,您可能會看到僅透過開發人員搶先體驗計畫提供的 API 方法或欄位。如要測試及預覽最新預先發布版功能,並提供意見回饋,請加入開發人員預覽版計畫。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間: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)"]]