> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Channels

> Query chat channels by type, membership, tags, deletion state, archive state, or known channel IDs.

Use channel queries to build inboxes, public channel discovery, event chat lists, and moderation views. Query support is similar across platforms, but not identical: TypeScript and Flutter expose keyword/display-name style searching, while Android's public channel query builder focuses on type, membership, tags, and deleted-state filters.

## Filter Surface

| Filter            | TypeScript            | iOS                                       | Android                                      | Flutter                                      |
| ----------------- | --------------------- | ----------------------------------------- | -------------------------------------------- | -------------------------------------------- |
| Types             | `types`               | `types`                                   | `.types(...)` or type helpers                | `.types(...)` or type helpers                |
| Membership        | `membership`          | `filter`                                  | `.filter(...)` where the builder exposes it  | `.filter(...)`                               |
| Tags              | `tags`, `excludeTags` | `includingTags`, `excludingTags`          | `.includingTags(...)`, `.excludingTags(...)` | `.includingTags(...)`, `.excludingTags(...)` |
| Deleted state     | `isDeleted`           | `includeDeleted`                          | `.includeDeleted(...)`                       | `.includeDeleted(...)`                       |
| Name or keyword   | `displayName`         | Not exposed on `AmityChannelQueryOptions` | Not exposed on public query builder          | `.withKeyword(...)`                          |
| Archive exclusion | `excludeArchives`     | Not exposed                               | Not exposed                                  | `.excludeArchives(...)`                      |
| Sort              | `sortBy`              | Not exposed on current options            | Not exposed on public query builder          | `.sortBy(...)` with `LAST_ACTIVITY`          |
| Known IDs         | `channelIds`          | `getChannels(channelIds:)`                | `getChannels(channelIds)`                    | Not exposed in the current public repository |

## Parameters

| Parameter                       | Required | Description                                                                             |
| ------------------------------- | -------- | --------------------------------------------------------------------------------------- |
| `types`                         | No       | Channel types to include, such as community, live, or conversation.                     |
| `membership` / `filter`         | No       | Restrict results by the current user's relationship to the channel.                     |
| `tags` / `includingTags`        | No       | Include channels with specific app-defined tags.                                        |
| `excludeTags` / `excludingTags` | No       | Exclude channels with specific app-defined tags.                                        |
| `isDeleted` / `includeDeleted`  | No       | Include or exclude deleted channels where the platform exposes the filter.              |
| `displayName` / `keyword`       | No       | Search by name or keyword where supported by the platform SDK.                          |
| `excludeArchives`               | No       | Exclude channels archived by the current user where supported.                          |
| `sortBy`                        | No       | Sort channel lists where the platform exposes sort options.                             |
| Pagination controls             | No       | Use collection callbacks, live collections, or paging data to load additional channels. |

## Query A Channel List

Query channels with type, membership, tag, deletion, archive, search, and pagination options where each platform exposes them.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ChannelRepository } from '@amityco/ts-sdk';

  const unsubscribe = ChannelRepository.getChannels(
    {
      displayName: 'support',
      membership: 'member',
      types: ['community', 'live'],
      tags: ['support'],
      excludeTags: ['hidden'],
      isDeleted: false,
      excludeArchives: true,
      sortBy: 'lastActivity',
    },
    ({ data: channels, onNextPage, hasNextPage, loading, error }) => {
      if (error) handleError(error);

      if (!loading && channels) {
        renderResults(channels);
      }

      if (hasNextPage) onNextPage?.();
    },
  );

  unsubscribe();
  ```

  ```swift iOS theme={null}
  let options = AmityChannelQueryOptions(
      types: Set([AmityChannelQueryType.community, AmityChannelQueryType.live]),
      filter: .userIsMember,
      includingTags: ["support"],
      excludingTags: ["hidden"],
      includeDeleted: false
  )

  let channels = channelRepository.getChannels(with: options)
  token = channels.observe { collection, error in
      if let error {
          handleError(error)
          return
      }

      showSuccessMessage(collection.snapshots.count)
  }
  ```

  ```kotlin Android theme={null}
  val includingTags = AmityTags().apply { add("support") }
  val excludingTags = AmityTags().apply { add("hidden") }

  val disposable = channelRepository
      .getChannels()
      .types(listOf(AmityChannel.Type.COMMUNITY, AmityChannel.Type.LIVE))
      .filter(AmityChannelFilter.MEMBER)
      .includingTags(includingTags)
      .excludingTags(excludingTags)
      .includeDeleted(includeDeleted = false)
      .build()
      .query()
      .subscribe(
          { pagingData -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final liveCollection = AmityChatClient.newChannelRepository()
      .getChannels()
      .withKeyword('support')
      .filter(AmityChannelFilter.MEMBER)
      .types([AmityChannelType.COMMUNITY, AmityChannelType.LIVE])
      .includingTags(['support'])
      .excludingTags(['hidden'])
      .includeDeleted(false)
      .excludeArchives(true)
      .sortBy(AmityChannelSortOption.LAST_ACTIVITY)
      .getLiveCollection();

  liveCollection.getStreamController().stream.listen((channels) {
    final count = channels.length;
  });

  await liveCollection.loadNext();
  ```
</CodeGroup>

## Query A Specific Type

Use the type-specific helpers when the platform exposes them. Some helpers apply membership defaults: for example, Flutter's `conversationType()` and `liveType()` also set the filter to `MEMBER`.

Use type-specific channel queries when your UI needs a focused list such as conversations or live channels.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ChannelRepository } from '@amityco/ts-sdk';

  const unsubscribe = ChannelRepository.getChannels(
    {
      types: ['conversation'],
      membership: 'member',
      isDeleted: false,
    },
    ({ data: channels }) => {
      renderResults(channels);
    },
  );

  unsubscribe();
  ```

  ```swift iOS theme={null}
  let options = AmityChannelQueryOptions(
      types: Set([AmityChannelQueryType.conversation]),
      filter: .userIsMember,
      includeDeleted: false
  )

  let conversations = channelRepository.getChannels(with: options)
  showSuccessMessage(conversations)
  ```

  ```kotlin Android theme={null}
  val disposable = channelRepository
      .getChannels()
      .conversationType()
      .includeDeleted(includeDeleted = false)
      .build()
      .query()
      .subscribe(
          { pagingData -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final conversations = AmityChatClient.newChannelRepository()
      .getChannels()
      .conversationType()
      .includeDeleted(false)
      .excludeArchives(true)
      .getLiveCollection();

  conversations.getStreamController().stream.listen((channels) {
    final count = channels.length;
  });
  ```
</CodeGroup>

## Known IDs

If you already have channel IDs, use [Get Channels](./get-channel) instead of a filtered query. Batch get-by-IDs is currently exposed on TypeScript, iOS, and Android.

## Related Topics

<CardGroup cols={2}>
  <Card title="Create Channels" href="./create-channel" icon="plus">
    Create a channel before it appears in query results.
  </Card>

  <Card title="Get Channels" href="./get-channel" icon="file">
    Retrieve a single channel or a known list of IDs.
  </Card>

  <Card title="Archive Channels" href="./archive-channels" icon="box-archive">
    Hide or restore archived conversation channels where supported.
  </Card>

  <Card title="Query Members" href="../members/query-members" icon="users">
    Query members after selecting a channel.
  </Card>
</CardGroup>
