PythonAsyncioAsyncioTwistedTornadoNativePython-aiohttp V4 Channel Groups API Reference for Realtime Apps

 

These docs are for PubNub 4.0 for Python-aiohttp V4 which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Python, PubNub 3.0 for Python-Tornado and PubNub 3.0 for Python-Twisted.

If you have questions about the PubNub for Python SDK, please contact us at support@pubnub.com.

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

Learn more about our Channel Groups here


Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
This function adds a channel to a channel group.
Adding Channels is accomplished by using the following method(s) in the Python-aiohttp V4 SDK:
 

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

  1. ParameterTypeRequiredDescription
    channelsString | List | TupleYesThe channel to add to the channel_group.
    channel_groupStringYesThe channel_group to add the channels to.
envelope = await pubnub.add_channel_to_channel_group().\
    channels(["ch1", "ch2"]).\
    channel_group("cg1").\
    future()

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
This function lists all the channels of the channel group.
Listing Channels is accomplished by using the following method(s) in the Python-aiohttp V4 SDK:
  1. ParameterTypeRequiredDescription
    channel_groupStringYesThe channel group to fetch channels.
envelope = pubnub.list_channels_in_channel_group().\
    channel_group("cg1").future()

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
This function removes the channels from the channel group.
Removing Channels is accomplished by using the following method(s) in the Python-aiohttp V4 SDK:
  1. ParameterTypeRequiredDescription
    channelsString | List | TupleYesThe channels to remove from the channel group.
    channel_groupStringYesSpecifies channel_group to remove the channels from.
envelope = await pubnub.remove_channel_from_channel_group().\
    channels(["son", "daughter"]).\
    channel_group("channel_group").\
    future()

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
This function removes the channel group.
Deleting Channel Group is accomplished by using the following method(s) in the Python-aiohttp V4 SDK:
  1. ParameterTypeRequiredDescription
    channel_groupStringYesThe channel group to remove.
envelope = await pubnub.remove_channel_group().\
    channel_group("cg1").future()