Messages are always sent through PubNub on a channel. You don't have to define channels in advance; the act of publishing a message creates the channel if it doesn't already exist. Some common uses of channels are to carry direct messages, group chats, broadcasts, fan-in message patterns, and more.
PubNub supports an unlimited number of channels. A channel name can be any alphanumeric string up to 92 characters. There are a few invalid characters, and some that are reserved for special features.
Channels can represent any place where messages are sent. For example, a channel meant for 1-to-1 direct chat simply means that there are only two users using that channel. A group channel means there are two or more users using that channel.
Here are some useful channel configurations:
Direct channels for 1-to-1 messaging between two users. You can make these channels private to keep the messages secure between the users.
Group channels for group messaging between multiple users. For instance, a chat room for your family, or for a group of friends. You can make these channels made public to allow anyone to join, or make them private and only allow select users to join them.
Broadcast channels for announcements, polls, and other situations in which you want to broadcast messages in a one-to-many arrangement.
Unicast channels for responses, sensor inputs, location data, and other situations in which you want to aggregate messages in a many-to-one arrangement.
You can optionally store channel metadata such as a name and description. You can also use a custom field to store additional data for each user. Some examples of custom data could include a channel's type, purpose, or owner.
Clients can receive events to get notified when the metadata is updated or removed in a channel. Refer to the Listeners & Events section for more details.
|Yes||The channel's unique identifier. Must not be empty. Supports UTF-8. Must be no more than 92 bytes in length.|
|Yes||The channel's name. Must not be empty, or consist only of whitespace characters.|
|No||The description of the channel.|
|No||JSON object of key-value pairs with supported data types. Values must be scalar only; arrays and objects aren't supported.|
Set channel metadata
This operation enables you to store channel metadata in PubNub and optionally include custom data.
Get channel metadata
Returns metadata for a specific channel and optionally includes custom data.
Get metadata for all channels
Returns a paginated list with metadata for all channels, optionally including each channel's custom data object.
Update channel metadata
Updates a channel with the specified properties. Returns the updated metadata, optionally including the channel's custom data object.
You can change any metadata, except the
id. If you update the custom property, you must completely replace it; partial updates aren't supported.
Delete channel metadata
This server-side operation deletes the metadata for a specified channel.