---
source_url: https://www.pubnub.com/docs/sdks/twisted/api-reference/channel-groups
title: Channel Groups API for Python-Twisted SDK
updated_at: 2026-05-21T15:47:44.084Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Channel Groups API for Python-Twisted SDK

:::note 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](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) allow PubNub developers to bundle thousands of [channels](https://www.pubnub.com/docs/general/channels/overview) 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.

:::note 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

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) 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:

:::note Maximum number of channels
You can add up to 200 channels to a channel group per API call.
:::

```python
pubnub.add_channel_to_channel_group().channels(String|List|Tuple).channel_group(String)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channels | String | Yes |  | The channels to add to the channel group. |
| channel_group | String | Yes |  | The channel group to add the channels to. |

### Sample code

#### Add channels

```python
d = pubnub.add_channel_to_channel_group().\
    channels(["ch1", "ch2"]).\
    channel_group("cg1").\
    deferred()

d.addCallback(my_callback)
```

## List channels in a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) 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:

```python
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

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

## Remove channels from a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) 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:

```python
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

```python
# 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

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on enabled for your key in the [Admin Portal](https://admin.pubnub.com/) (with Enable Wildcard Subscribe checked). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) 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:

```python
pubnub.remove_channel_group().channel_group(String)
```

| Parameter | Description |
| --- | --- |
| `channel_group` *Type: String | The channel group to remove. |

### Sample code

#### Delete channel group

```python
# 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)
```