Get metadata for all channels

Showing JavaScript examples.
Starting a new app? Use DataSync

DataSync 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 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 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 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.

1

If Access Manager 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 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 for the exact parameter shape.

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

1

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 for the full field list, operators, and syntax.

1

List channels without code​

BizOps Workspace'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 for the quick search box, the Filters button, and advanced filtering with the same expression language as filter.

Was this page useful?

Last updated on