List spaces in a section

This guide explains how to use the list method on the SectionItem resource of the Google Chat API to list items (such as spaces) in a section.

Only spaces can be section items. For more information, see Create and organize sections in Google Chat.

Prerequisites

Python

List spaces in a section

To list spaces in a section with user authentication, pass the following in your request:

  • Specify the chat.users.sections or chat.users.sections.readonly authorization scope.
  • Call the ListSectionItems method.
  • Set parent to the resource name of the section.

The following example lists spaces in a section:

Python

fromgoogle.cloudimport chat_v1
deflist_section_items():
 # Create a client
 client = chat_v1.ChatServiceClient()
 # Initialize request
 request = chat_v1.ListSectionItemsRequest(
 parent="SECTION_NAME"
 )
 # Make the request
 page_result = client.list_section_items(request=request)
 # Handle the response
 for item in page_result:
 print(item)

To run this sample, replace the following:

  • SECTION_NAME: The resource name of the section. You can obtain the resource name by calling the ListSections method.

The Chat API returns a list of SectionItem resources.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年04月20日 UTC.