---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/list
title: List all channels
updated_at: 2026-06-12T11:23:12.673Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# List all channels

Get a paginated list of all channels with `getChannels()`. Custom channel metadata is included by default.

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) for your keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

To list channels a user belongs to, use [getMemberships()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-membership) instead.

### Method signature

This method takes the following parameters:

```swift
chat.getChannels(
    filter: String? = nil,
    sort: [PubNub.ObjectSortField] = [],
    limit: Int? = nil,
    page: PubNubHashedPage? = nil,
) async throws -> (channels: [ChannelImpl], page: PubNubHashedPage?)
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| filter | String | Optional |  | Expression used to filter the results. Returns only these channels whose properties satisfy the given expression are returned. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| sort | [PubNub.ObjectSortField] | Optional | `[]` | A collection to specify the sort order. Available options are `id`, `name`, and `updated`. Use `asc` or `desc` to specify the sorting direction, or specify `null` to take the default sorting direction (ascending). For example: `{name: "asc"}`. Unless specified otherwise, the items are sorted by the last updated date. Defaults to an empty list. |
| limit | Int | Optional | `nil` | Number of objects to return in response. The default (and maximum) value is `100`. |
| page | PubNubHashedPage? | Optional | `nil` | Object used for pagination to define which previous or next result page you want to fetch. |

#### Output

| Parameter | Description |
| --- | --- |
| `(channels: [ChannelImpl], page: PubNubHashedPage?)` | A tuple containing a set of channels and pagination information indicating the start, end, and total count of the members. |

### Sample code

:::tip Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
:::

Fetch all existing channel IDs.

```swift
// Assumes a "ChatImpl" reference named "chat"
Task {
  // Fetch the first set of channels.
  // There's no need to pass the "page" parameter, as it's nil by default, indicating the first page
  let getChannelsResult = try await chat.getChannels()
  debugPrint("Fetched channels: \(getChannelsResult.channels)")
  debugPrint("Next page: \(String(describing: getChannelsResult.page))")
    
  // The example below shows how to read the next page and pass it to a subsequent call.
  // You can recursively keep fetching using the page objects from previous responses until the returned array is empty
  if let nextPage = getChannelsResult.page, !getChannelsResult.channels.isEmpty {
    let resultsFromNextPage = try await chat.getChannels(page: nextPage)
  }
}
```

### Other examples

#### Pagination

Get the first 25 channels and then fetch results from the next page using a page previously returned from the PubNub server.

```swift
// Assumes a "ChatImpl" reference named "chat"
// Assumes a "PubNubHashedPage" reference named "page"
Task {
  let getChannelsResult = try await chat.getChannels(limit: 25, page: page)
  debugPrint("Fetched channels: \(getChannelsResult.channels)")
  debugPrint("Next page: \(String(describing: getChannelsResult.page))")
    
  // The example below shows how to read the next page and pass it to a subsequent call.
  // You can recursively keep fetching using the page objects from previous responses until the returned array is empty
  if let nextPage = getChannelsResult.page, !getChannelsResult.channels.isEmpty {
    let resultsFromNextPage = try await chat.getChannels(limit: 25, page: nextPage)
  }
}
```

#### Archived channels

Get all archived channels. This request will return all channels removed with the `soft` option set to `true`, whose data is still stored in the App Context storage.

```swift
// Assumes a "ChatImpl" reference named "chat"
// Assumes a "PubNubHashedPage" reference named "page"
Task {
  let getChannelsResult = try await chat.getChannels(filter: "status == 'deleted'", limit: 25, page: page)
  debugPrint("Fetched channels: \(getChannelsResult.channels)")
  debugPrint("Next page: \(String(describing: getChannelsResult.page))")
    
  // The example below shows how to read the next page and pass it to a subsequent call.
  // You can recursively keep fetching using the page objects from previous responses until the returned array is empty
  if let nextPage = getChannelsResult.page, !getChannelsResult.channels.isEmpty {
    let resultsFromNextPage = try await chat.getChannels(page: nextPage)
  }
}
```