Channel Groups API for PubNub Python-Asyncio SDK

Channel groups allow PubNub developers to bundle thousands of channels into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.

Channel group operations

You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.

Add Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function adds a channel to a channel group.

Method(s)

Adding Channels is accomplished by using the following method(s) in the Python-asyncio SDK:

Maximum number of channels

200 channels can be added to the channel group per API call.

pubnub.add_channel_to_channel_group() \
.channels(String|List|Tuple) \
.channel_group(String)
ParameterTypeRequiredDescription
channelsString | List | TupleYesThe channel to add to the channel_group.
channel_groupStringYesThe channel_group to add the channels to.

Basic Usage

Add Channels

envelope = await pubnub.add_channel_to_channel_group().\
channels(["ch1", "ch2"]).\
channel_group("cg1").\
future()

List Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function lists all the channels of the channel group.

Method(s)

Listing Channels is accomplished by using the following method(s) in the Python-asyncio SDK:

pubnub.list_channels_in_channel_group() \
.channel_group(String)
ParameterTypeRequiredDescription
channel_groupStringYesThe channel group to fetch channels.

Basic Usage

List Channels

envelope = pubnub.list_channels_in_channel_group().\
channel_group("cg1").future()

Remove Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function removes the channels from the channel group.

Method(s)

Removing Channels is accomplished by using the following method(s) in the Python SDK:

pubnub.remove_channel_from_channel_group() \
.channels(String|List|Tuple) \
.channel_group(String)
ParameterTypeRequiredDescription
channelsString | List | TupleYesThe channels to remove from the channel group.
channel_groupStringYesSpecifies channel_group to remove the channels from.

Basic Usage

Remove channels

envelope = await pubnub.remove_channel_from_channel_group().\
channels(["son", "daughter"]).\
channel_group("channel_group").\
future()

Delete Channel Group

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function removes the channel group.

Method(s)

Deleting Channel Group is accomplished by using the following method(s) in the Python SDK:

pubnub.remove_channel_group() \
.channel_group(String)
ParameterTypeRequiredDescription
channel_groupStringYesThe channel group to remove.

Basic Usage

Delete Channel Group

envelope = await pubnub.remove_channel_group() \
.channel_group("cg1").future()
Last updated on