Tổng quan về API Google Chat
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này cung cấp thông tin tổng quan về cách sử dụng Google Chat API và tài liệu tham khảo của API này.
Google Chat API có cả giao diện gRPC và REST, cũng như thư viện ứng dụng hỗ trợ cả hai. Nếu các thư viện ứng dụng được cung cấp không đáp ứng nhu cầu của bạn, thì bạn có thể viết thư viện ứng dụng của riêng mình bằng giao diện gRPC hoặc REST.
Thư viện ứng dụng
Cách mà hầu hết nhà phát triển nên dùng để gọi Google Chat API là sử dụng Thư viện ứng dụng đám mây được hỗ trợ chính thức cho ngôn ngữ mà bạn muốn, chẳng hạn như Python, Java hoặc Node.js.
Nếu bạn đang viết mã bằng Google Apps Script, hãy sử dụng dịch vụ Chat nâng cao thay vì cài đặt một thư viện ứng dụng.
Tên loại, phương thức và trường
Tuỳ thuộc vào việc bạn đang sử dụng thư viện ứng dụng, gRPC hay REST, loại, phương thức và tên trường cho API Google Chat sẽ có một số điểm khác biệt:
- Thư viện ứng dụng đám mây được sắp xếp theo các dịch vụ gRPC và phương thức của các dịch vụ đó.
Thư viện ứng dụng Google API được sắp xếp dưới dạng các dịch vụ chứa các đối tượng hoặc lớp tương ứng với tài nguyên REST, đồng thời chứa các phương thức tương ứng.
- gRPC được sắp xếp theo các dịch vụ và phương thức của chúng.
- REST được sắp xếp theo hệ thống phân cấp tài nguyên và các phương thức của chúng.
- Tên trường gRPC sử dụng kiểu chữ snake case.
- Tên trường REST sử dụng kiểu lạc đà, mặc dù dịch vụ API sẽ chấp nhận cả kiểu lạc đà hoặc kiểu rắn.
- Tên trường thư viện ứng dụng sử dụng chữ cái đầu viết hoa, chữ hoa chữ thường hoặc chữ thường phân tách bằng dấu gạch dưới, tuỳ thuộc vào tên nào phù hợp với ngôn ngữ.
Vùng đệm giao thức
Cho dù bạn đang sử dụng thư viện ứng dụng, REST hay gRPC, dịch vụ cơ bản đều được xác định bằng các vùng đệm giao thức. Cụ thể, dịch vụ này sử dụng proto3.
Khi gọi API, một số trường yêu cầu hoặc phản hồi có thể yêu cầu bạn hiểu cơ bản về các loại bộ đệm giao thức nổi tiếng.
Ngoài ra, khi gọi REST API, hành vi giá trị mặc định cho các vùng đệm giao thức có thể dẫn đến việc thiếu các trường trong phản hồi JSON. Các trường này được đặt thành giá trị mặc định, nên không có trong phản hồi.
Phiên bản API
Các phiên bản API sau đây hiện có:
Bản dùng thử cho nhà phát triển
Trong tài liệu, bạn có thể thấy các phương thức hoặc trường API chỉ có trong Chương trình Bản dùng thử cho nhà phát triển. Để kiểm thử, xem trước và đưa ra ý kiến phản hồi về các tính năng dùng thử mới nhất, hãy tham gia Chương trình dùng thử cho nhà phát triển.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[[["\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)"]]