Method: spaces.list
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แสดงรายการพื้นที่ทำงานที่ผู้โทรเป็นสมาชิก แชทเป็นกลุ่มและ DM จะไม่แสดงจนกว่าจะมีการส่งข้อความแรก ดูตัวอย่างได้ที่แสดงรายการพื้นที่ทำงาน
รองรับการตรวจสอบสิทธิ์ประเภทต่อไปนี้
หากต้องการแสดงรายการพื้นที่ทำงานที่มีชื่อทั้งหมดตามองค์กร Google Workspace ให้ใช้เมธอด spaces.search()
โดยใช้สิทธิ์ของผู้ดูแลระบบ Workspace แทน
คำขอ HTTP
GET https://chat.googleapis.com/v1/spaces
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์การค้นหา
พารามิเตอร์ |
pageSize |
integer
ไม่บังคับ จำนวนพื้นที่ทำงานสูงสุดที่จะแสดง บริการอาจแสดงผลน้อยกว่าค่านี้ หากไม่ระบุ ระบบจะแสดงผลไม่เกิน 100 ช่องว่าง ค่าสูงสุดคือ 1,000 หากคุณใช้ค่ามากกว่า 1,000 ระบบจะเปลี่ยนค่าเป็น 1,000 โดยอัตโนมัติ ค่าลบจะแสดงผลข้อผิดพลาด INVALID_ARGUMENT
|
pageToken |
string
ไม่บังคับ โทเค็นหน้าเว็บที่ได้รับจากการเรียกใช้รายการพื้นที่ทำงานก่อนหน้านี้ ระบุพารามิเตอร์นี้เพื่อดึงข้อมูลหน้าถัดไป เมื่อแบ่งหน้า ค่าตัวกรองควรตรงกับคอลที่ระบุโทเค็นหน้า การส่งค่าอื่นอาจทําให้ได้ผลลัพธ์ที่ไม่คาดคิด
|
filter |
string
ไม่บังคับ ตัวกรองข้อความค้นหา คุณสามารถกรองพื้นที่ทำงานตามประเภทพื้นที่ทำงาน (spaceType ) หากต้องการกรองตามประเภทพื้นที่ทำงาน คุณต้องระบุค่า Enum ที่ถูกต้อง เช่น 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 )
รายการพื้นที่ทำงานในหน้าที่ขอ (หรือหน้าแรก) หมายเหตุ: ระบบจะไม่แสดงฟิลด์ 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
ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\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)."]]