---
source_url: https://www.pubnub.com/docs/data-storage/metadata/get-metadata-for-all-channels
title: Get metadata for all channels
updated_at: 2026-09-30T07:20:08.000Z
---

# Get metadata for all channels

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

:::note Starting a new app? Use DataSync
[DataSync](https://www.pubnub.com/docs/data-storage/structured-data/overview.md) is the successor to App Context. It does everything App Context does for users, channels, and memberships, and adds typed schemas, partial updates with ETags, field-level access control, and per-class expiry. Refer to [How DataSync compares to App Context](https://www.pubnub.com/docs/data-storage/structured-data/overview.md) for a feature-by-feature comparison.
DataSync is currently available to new accounts and to accounts that are not actively using App Context. If your keysets already use App Context, keep using it for now. App Context remains fully supported and these pages stay accurate.
:::

This guide shows you how to retrieve [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md) metadata for every channel on your keyset instead of one, page through the results, and sort or filter them. App Context must be enabled on the keyset before you call it, and new keysets don't enable it by default. To read, write, or remove one channel's own record, refer to [Set, get, and remove channel metadata](https://www.pubnub.com/docs/data-storage/metadata/manage-channel-metadata.md) instead.

## Get all channel metadata

Call `Get All Channel Metadata` with no channel name. Pass `include.customFields` to receive each channel's `custom` object, and `include.totalCount` to receive the total number of channels on the keyset alongside the page you asked for.

### JavaScript

```javascript
// Get the total number of channels included in the response.
try {
  const response = await pubnub.objects.getAllChannelMetadata({
    include: {
      totalCount: true,
    },
  });
} catch (error) {
  console.error(`Get all channel metadata error: ${error}`);
}

// Get all channels with the filter option. To get all channel which has Id ending 'Team'.
try {
  const response = await pubnub.objects.getAllChannelMetadata({
    filter: 'name LIKE "*Team"',
  });
  console.log('Get all channel metadata response:', response);
} catch (error) {
  console.error(`Get all channel metadata error: ${error}`);
}
```

### Java

```java
PNGetAllChannelsMetadataResult pnGetAllChannelsMetadataResult = pubNub.getAllChannelsMetadata().sync();
```

### Kotlin

```kotlin
pubnub.getAllChannelMetadata()
    .async { result ->
        result.onFailure { exception ->
            // Handle error
        }.onSuccess { value ->
            // Handle successful method result
        }
    }
```

### C#

```csharp
using PubnubApi;

// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = new Pubnub(pnConfiguration);
        
PNResult<PNGetAllChannelMetadataResult> getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata()
    .IncludeCount(true)
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetAllChannelMetadataResult getAllChannelMetadataResult = getAllChannelMetadataResponse.Result;
PNStatus status2 = getAllChannelMetadataResponse.Status;
```

### Go

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"
	"time"

	pubnub "github.com/pubnub/go/v10"
)

// Example_getAllChannelMetadataWithIncludes demonstrates listing all channels with all include options
func Example_getAllChannelMetadataWithIncludes() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo"
	config.PublishKey = "demo"

	pn := pubnub.NewPubNub(config)

	// Create channel with all fields
	pn.SetChannelMetadata().
		Channel("channel-all-list-1").
		Name("Full Channel").
		Custom(map[string]interface{}{"priority": "high"}).
		Status("active").
		Type("team").
		Execute()

	// Get all channels with all include options
	response, status, err := pn.GetAllChannelMetadata().
		Include([]pubnub.PNChannelMetadataInclude{
			pubnub.PNChannelMetadataIncludeCustom, // Include custom fields
			pubnub.PNChannelMetadataIncludeStatus, // Include status field
			pubnub.PNChannelMetadataIncludeType,   // Include type field
		}).
		Limit(10).
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 && len(response.Data) > 0 {
		fmt.Println("Retrieved channels with all metadata fields")
	}

	// Output:
	// Retrieved channels with all metadata fields
}
```

### Swift

```swift
// Retrieve all channel metadata
pubnub.allChannelMetadata { result in
  switch result {
  case let .success(response):
    print("The channel metadata objects \(response.channels)")
    print("The next page used for pagination: \(String(describing: response.next))")
  case let .failure(error):
    print("Fetch All request failed with error: \(error.localizedDescription)")
  }
}
```

### PHP

```php
$getAllChannelMetadataResult = $pubnub->getAllChannelMetadata()
    ->includeFields(['customFields' => true, 'totalCount' => true])
    ->limit(10)
    ->sync();
assert(count($getAllChannelMetadataResult->getData()) >= 2);
```

### Unity

```csharp
using PubnubApi;
using PubnubApi.Unity;

// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

PNResult<PNGetAllChannelMetadataResult> getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata()
    .IncludeCount(true)
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetAllChannelMetadataResult getAllChannelMetadataResult = getAllChannelMetadataResponse.Result;
PNStatus status2 = getAllChannelMetadataResponse.Status;
```

If [Access Manager](https://www.pubnub.com/docs/security/access-control/overview.md) is enabled, the option for this call is **Disallow Get All Channel Metadata**. An App Context "get all" call needs no per-resource permission grant unless you've turned on the matching **Disallow Get All** option, in which case the token needs an explicit grant for that operation. Refer to [App Context and access control](https://www.pubnub.com/docs/data-storage/metadata/overview.md#app-context-and-access-control) for the full permission model.

## Page through the list

Every paginated App Context call takes the same three parameters. `limit` caps how many records come back in one call. It defaults to 100, and 100 is also the maximum. `page.next` and `page.prev` are opaque cursor strings copied from a previous response: pass the one you want to continue from, and PubNub returns the adjacent page in that direction. If you supply both, PubNub uses `next` and ignores `prev`.

To retrieve every channel, keep calling `Get All Channel Metadata` with `page.next` set to the `next` value from the previous response. Stop when a response returns no `next` value. That's the last page.

## Sort the list

Pass `sort` to order the results by `id`, `name`, or `updated`, each with an ascending or descending direction, for example `{name: 'asc'}`. Without a `sort` parameter, the order isn't guaranteed to stay stable between calls. Check your platform's API reference in [Available SDKs](https://www.pubnub.com/docs/sdks.md) for the exact parameter shape.

The following example, in PHP, sorts both a user list and a channel list by name:

```php
// Sort users by name ascending
$sortedUsersAscResult = $pubnub->getAllUuidMetadata()
    ->sort(['name' => 'asc'])
    ->limit(5)
    ->sync();

echo "Users sorted by name (ascending): " . count($sortedUsersAscResult->getData()) . "\n";
foreach ($sortedUsersAscResult->getData() as $user) {
    echo "  - " . ($user->getName() ?: $user->getId()) . "\n";
}

// Sort users by updated time descending
$sortedUsersDescResult = $pubnub->getAllUuidMetadata()
    ->sort(['updated' => 'desc'])
    ->limit(3)
    ->sync();

echo "Users sorted by updated time (descending): " . count($sortedUsersDescResult->getData()) . "\n";

// Sort channels by name
$sortedChannelsResult = $pubnub->getAllChannelMetadata()
    ->sort(['name' => 'asc'])
    ->limit(5)
    ->sync();

echo "Channels sorted by name: " . count($sortedChannelsResult->getData()) . "\n";
```

## Filter the list

Pass `filter` to receive only the channels matching a filter expression, such as `status == "active"` or `name LIKE "team.*"`, instead of paging through every channel and filtering client-side. Refer to [App Context filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md) for the full field list, operators, and syntax.

```php
// Filter users by custom field (note: filtering by custom properties may have limitations)
$filteredUsersResult = $pubnub->getAllUuidMetadata()
    ->includeFields(['customFields' => true])
    ->filter("name LIKE '*Alice*'")
    ->sync();

echo "Filtered users (name contains 'Alice'): " . count($filteredUsersResult->getData()) . "\n";

// Filter channels by name
$filteredChannelsResult = $pubnub->getAllChannelMetadata()
    ->includeFields(['customFields' => true])
    ->filter("name LIKE '*General*'")
    ->sync();

echo "Filtered channels (name contains 'General'): " . count($filteredChannelsResult->getData()) . "\n";
```

## List channels without code

[BizOps Workspace](https://www.pubnub.com/docs/data-storage/metadata/overview.md)'s **Channel Management** module lists every channel on your keyset with the same filter and sort options, with no SDK call required. Refer to [Channel Management filters](https://www.pubnub.com/docs/data-storage/metadata/manage-channel-metadata.md) for the quick search box, the **Filters** button, and advanced filtering with the same expression language as `filter`.

## Related tasks

* [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md). The three entity types and how App Context relates to messages and [Presence](https://www.pubnub.com/docs/presence/overview.md).
* [Set, get, and remove channel metadata](https://www.pubnub.com/docs/data-storage/metadata/manage-channel-metadata.md). Read, write, or remove one channel's own record.
* [App Context filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). The full filter field list, operators, and syntax.
* [App Context API limits](https://www.pubnub.com/docs/data-storage/metadata/api-limits.md). Recommended maximum channel metadata records per keyset.

Last updated at: 2026-09-30T07:20:08.000Z
