Method: spaces.list
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
列出呼叫端的聊天室成員。群組通訊和即時訊息必須先傳送第一則訊息,系統才會列出相關資訊。如需範例,請參閱「列出聊天室」。
支援下列類型的驗證:
使用授權範圍的應用程式驗證:
https://www.googleapis.com/auth/chat.bot
使用下列其中一個授權範圍進行使用者驗證:
https://www.googleapis.com/auth/chat.spaces.readonly
https://www.googleapis.com/auth/chat.spaces
如要依 Google Workspace 機構列出所有命名空間,請改用 spaces.search()
方法,並使用 Workspace 管理員權限。
HTTP 要求
GET https://chat.googleapis.com/v1/spaces
這個網址使用 gRPC 轉碼語法。
查詢參數
參數 |
pageSize |
integer
(非必要) 要傳回的空格數量上限。服務傳回的產品數量可能會少於這個值。 如未指定,最多會傳回 100 個空間。 值的上限為 1000。如果您使用的值超過 1000,系統會自動將其變更為 1000。 負值會傳回 INVALID_ARGUMENT 錯誤。
|
pageToken |
string
(非必要) 接收自先前 list spaces 呼叫的頁面權杖。提供這個參數即可擷取後續網頁。 進行分頁時,篩選器值應與提供網頁權杖的呼叫相符。傳遞其他值可能會導致非預期的結果。
|
filter |
string
(非必要) 查詢篩選器。 您可以依據聊天室類型 (spaceType ) 篩選聊天室。 如要依空間類型篩選,您必須指定有效的列舉值,例如 SPACE 或 GROUP_CHAT (spaceType 不能是 SPACE_TYPE_UNSPECIFIED )。如要查詢多個空間類型,請使用 OR 運算子。 舉例來說,以下查詢有效:
spaceType = "SPACE"
spaceType = "GROUP_CHAT" OR spaceType = "DIRECT_MESSAGE"
伺服器會拒絕無效的查詢,並傳回 INVALID_ARGUMENT 錯誤。
|
回應主體
清單聊天室要求的回應。
如果成功,回應主體會含有以下結構的資料:
JSON 表示法 |
{
"spaces": [
{
object (Space )
}
],
"nextPageToken": string
} |
欄位 |
spaces[] |
object (Space )
要求 (或第一個) 頁面中的聊天室清單。注意:清單要求不會在 Space 物件中傳回 permissionSettings 欄位。
|
nextPageToken |
string
您可以傳送符記做為 pageToken ,用於擷取下一頁的結果。如果留空,表示沒有後續網頁。
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/chat.spaces
https://www.googleapis.com/auth/chat.spaces.readonly
https://www.googleapis.com/auth/chat.bot
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eLists spaces (excluding empty group chats and DMs) that the caller is a member of, supporting app and user authentication.\u003c/p\u003e\n"],["\u003cp\u003eAllows filtering by space type and pagination for retrieving large result sets.\u003c/p\u003e\n"],["\u003cp\u003eRequires specific authorization scopes related to Google Chat spaces and bots.\u003c/p\u003e\n"],["\u003cp\u003eProvides details on the HTTP request structure, query parameters, and expected response.\u003c/p\u003e\n"],["\u003cp\u003eTo list all spaces within a Google Workspace organization, use the \u003ccode\u003espaces.search()\u003c/code\u003e method with administrator privileges.\u003c/p\u003e\n"]]],["This document details how to list spaces a user is a member of via an HTTP `GET` request to `https://chat.googleapis.com/v1/spaces`. Key actions include utilizing optional query parameters like `pageSize`, `pageToken`, and `filter` to manage results. The request body must be empty. The response body returns an array of `spaces` and a `nextPageToken` for pagination. Authorization requires specific OAuth scopes, and alternative options exist for listing spaces by Google Workspace organization.\n"],null,["# Method: spaces.list\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ListSpacesResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nLists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see [List spaces](https://developers.google.com/workspace/chat/list-spaces).\n\nSupports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):\n\n- [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with the authorization scope:\n\n - `https://www.googleapis.com/auth/chat.bot`\n- [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes:\n\n - `https://www.googleapis.com/auth/chat.spaces.readonly`\n - `https://www.googleapis.com/auth/chat.spaces`\n\nTo list all named spaces by Google Workspace organization, use the [`spaces.search()`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search) method using Workspace administrator privileges instead.\n\n### HTTP request\n\n`GET https://chat.googleapis.com/v1/spaces`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `pageSize` | `integer` Optional. The maximum number of spaces to return. The service might return fewer than this value. If unspecified, at most 100 spaces are returned. The maximum value is 1000. If you use a value more than 1000, it's automatically changed to 1000. Negative values return an `INVALID_ARGUMENT` error. |\n| `pageToken` | `string` Optional. A page token, received from a previous list spaces call. Provide this parameter to retrieve the subsequent page. When paginating, the filter value should match the call that provided the page token. Passing a different value may lead to unexpected results. |\n| `filter` | `string` Optional. A query filter. You can filter spaces by the space type ([`spaceType`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#spacetype)). To filter by space type, you must specify valid enum value, such as `SPACE` or `GROUP_CHAT` (the `spaceType` can't be `SPACE_TYPE_UNSPECIFIED`). To query for multiple space types, use the `OR` operator. For example, the following queries are valid: spaceType = \"SPACE\" spaceType = \"GROUP_CHAT\" OR spaceType = \"DIRECT_MESSAGE\" Invalid queries are rejected by the server with an `INVALID_ARGUMENT` error. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nThe response for a list spaces request.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------|\n| ``` { \"spaces\": [ { object (/workspace/chat/api/reference/rest/v1/spaces#Space) } ], \"nextPageToken\": string } ``` |\n\n| Fields ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `spaces[]` | `object (`[Space](/workspace/chat/api/reference/rest/v1/spaces#Space)`)` List of spaces in the requested (or first) page. Note: The `permissionSettings` field is not returned in the Space object for list requests. |\n| `nextPageToken` | `string` You can send a token as `pageToken` to retrieve the next page of results. If empty, there are no subsequent pages. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.spaces`\n- `https://www.googleapis.com/auth/chat.spaces.readonly`\n- `https://www.googleapis.com/auth/chat.bot`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize)."]]