Channels
Channels in the Ripplefy system, facilitate simultaneous communication among multiple users. Each channel acts as a distinct messaging stream, allowing you to send a message to all users subscribing of a channel in a single operation. Notably, you don't need to predefine a channel; it is automatically created when users attempt to subscribe to it.
If certain users decide they no longer wish to receive messages from a specific channel, they can be unsubscribed from the channel by sending a request to the /channels/unsubscribe
endpoint.
Channel Subscription
POST /channels/subscribe
cURL
curl --location 'https://api.ripplesignal.co/channels/subscribe' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json' \
--data '{
"users": ["{your_userA_id}::{your_userA_session}", "{your_userB_id}::{your_userB_session}"],
"channel": "{channel}"
}'
Response
Status Code: 200 OK
{
"success": true
}
Unsubscribe from a Channel
POST /channels/unsubscribe
cURL
curl --location 'https://api.ripplesignal.co/channels/unsubscribe' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json' \
--data '{
"users": ["{your_userA_id}::{your_userA_session}", "{your_userB_id}::{your_userB_session}"],
"channel": "{channel}"
}'
Response
Status Code: 200 OK
{
"success": true
}
Retrieving User's Subscribed Channels
Use the following endpoint to retrieve the list of channels a user is subscribed to. Provide only the userID; you don't need to supply the session ID. The response will include all active sessions for that user associated with each channel.
cURL
curl --location 'https://api.ripplesignal.co/users/{user_id}' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json'
Response
Status Code: 200 OK
{
"channels": [
{
"channel": "{channel}",
"user_session": "{user_id}::{session_id}",
"updated_at": "{timestamp}"
}
]
}
Retrieving Connected Users
Retrieve a list of users currently connected to specified channels. If you omit the channel filter, the API returns a list of all connected users.
curl --request POST 'https://api.ripplesignal.co/channels/connections/search' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json' \
--data '{
"filters": {
"by_channels": ["channel1", "channel2"]
}
}'
To fetch the total count of users connected to specified channels, use the following endpoint:
curl --request POST 'https://api.ripplesignal.co/channels/connections/search/agg' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json' \
--data '{
"filters": {
"by_channels": ["channel1", "channel2"]
}
}'