Channel Groups API for Python-Twisted SDK
Deprecated
PubNub's Python Twisted SDK is deprecated as of May 1, 2019. We no longer update it, but we continue to support existing users. Consider using our other Python SDKs, which we actively maintain. If you need the Python Twisted SDK, contact us and we can work with you.
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 to a channel group
Requires Stream Controller add-on
This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.
This function adds channels to a channel group.
Method(s)
Adding Channels
is accomplished by using the following method(s) in the Python-Twisted SDK:
Maximum number of channels
You can add up to 200 channels to a channel group per API call.
pubnub.add_channel_to_channel_group().channels(String|List|Tuple).channel_group(String)
Parameter | Description |
---|---|
channels *Type: String | List | Tuple | The channels to add to the channel group. |
channel_group *Type: String | The channel group to add the channels to. |
Sample code
Add channels
d = pubnub.add_channel_to_channel_group().\
channels(["ch1", "ch2"]).\
channel_group("cg1").\
deferred()
d.addCallback(my_callback)
List channels in a channel group
Requires Stream Controller add-on
This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.
This function lists all channels in a channel group.
Method(s)
Listing Channels
is accomplished by using the following method(s) in the Python-Twisted SDK:
pubnub.list_channels_in_channel_group().channel_group(String)
Parameter | Description |
---|---|
channel_group *Type: String | The channel group to fetch channels from. |
Sample code
List channels
envelope = yield pubnub.list_channels_in_channel_group().\
channel_group("cg1").future()
Remove channels from a channel group
Requires Stream Controller add-on
This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.
This function removes channels from a channel group.
Method(s)
Removing Channels
is accomplished by using the following method(s) in the Python-Twisted SDK:
pubnub.remove_channel_from_channel_group().channels(String|List|Tuple).channel_group(String)
Parameter | Description |
---|---|
channels *Type: String | List | Tuple | The channels to remove from the channel group. |
channel_group *Type: String | The channel group to remove channels from. |
Sample code
Remove channels
# if we're using inlineCallbacks
envelope = yield pubnub.remove_channel_from_channel_group()\
.group(channel_group)\
.channels(["son", "daughter"])\
.deferred()
# if we're not using inlineCallbacks
d = pubnub.remove_channel_from_channel_group()\
.group(channel_group)\
.channels(["son", "daughter"])\
.deferred()
d.addCallback(my_callback)
Delete a channel group
Requires Stream Controller add-on
This method requires the Stream Controller add-on enabled for your key in the Admin Portal (with Enable Wildcard Subscribe checked). Read the support page on enabling add-on features.
This function removes the channel group.
Method(s)
Deleting Channel Group
is accomplished by using the following method(s) in the Python-Twisted SDK:
pubnub.remove_channel_group().channel_group(String)
Parameter | Description |
---|---|
channel_group *Type: String | The channel group to remove. |
Sample code
Delete channel group
# if we're using inlineCallbacks
envelope = yield pubnub.remove_channel_group()\
.group(channel_group)\
.deferred()
# if we're not using inlineCallbacks
d = pubnub.remove_channel_group()\
.group(channel_group)\
.deferred()
d.addCallback(my_callback)