Comments Channel
This WebSocket connection pushes new comments in real time as participants discuss Openfish events and markets. Unlike the CLOB-hosted channels, the comments endpoint runs on the gamma server. No authentication is needed to connect.
Endpoint
Section titled “Endpoint”wss://gamma.openfish.fun/ws/commentsProtocol
Section titled “Protocol”Subscribe
Section titled “Subscribe”Once connected, send a JSON message indicating which entity you want to follow:
{ "channel": "comments", "entity_type": "market", "entity_id": "abc123"}| Field | Type | Description |
|---|---|---|
channel | string | Must be "comments" |
entity_type | string | Entity type to subscribe to ("market" or "event") |
entity_id | string | The ID of the market or event |
Subscription Acknowledgment
Section titled “Subscription Acknowledgment”The server confirms with:
{ "type": "subscribed", "entityType": "market", "entityId": "abc123"}Changing Subscription
Section titled “Changing Subscription”To switch to a different entity, send another subscription message. The server replaces your current subscription rather than adding to it:
{ "channel": "comments", "entity_type": "event", "entity_id": "125819"}Comment Message Format
Section titled “Comment Message Format”Each time someone posts a comment on the entity you are following, the server delivers the full comment payload:
{ "type": "comment", "body": "I think YES is underpriced here.", "author": "0xce533188d53a16ed580fd5121dedf166d3482677", "entity_type": "market", "entity_id": "abc123", "parent_comment_id": null, "timestamp": 1700000000}| Field | Type | Description |
|---|---|---|
type | string | Always "comment" for new comment events |
body | string | The text content of the comment |
author | string | Wallet address of the comment author |
entity_type | string | Entity the comment belongs to ("market" or "event") |
entity_id | string | ID of the entity |
parent_comment_id | string/null | ID of the parent comment for replies, null for top-level |
timestamp | number | Unix timestamp in seconds |
Comment Threading
Section titled “Comment Threading”Replies are linked to their parents through the parent_comment_id field:
- Top-level comments have
parent_comment_idset tonull. - Reply comments reference the parent via
parent_comment_id.
All comments within a subscription belong to the same entity_type and entity_id.
Heartbeat
Section titled “Heartbeat”The server sends WebSocket PING frames every 10 seconds. Respond with PONG to keep the connection alive.
Rust SDK Example
Section titled “Rust SDK Example”use openfish_client_sdk::ws::CommentSocket;use futures_util::StreamExt;
#[tokio::main]async fn main() -> anyhow::Result<()> { let mut ws = CommentSocket::connect("wss://gamma.openfish.fun/ws/comments").await?;
// Subscribe to comments on a specific market ws.subscribe("market", "abc123").await?;
while let Some(comment) = ws.next().await { if let Some(parent_id) = &comment.parent_comment_id { println!(" Reply to {}: {}", parent_id, comment.body); } else { println!("New comment by {}: {}", comment.author, comment.body); } }
Ok(())}Building a Comment Feed
Section titled “Building a Comment Feed”You can bootstrap a complete comment view by loading historical data through REST, then switching over to the WebSocket for anything posted after that point:
use openfish_client_sdk::{GammaClient, ws::CommentSocket};use futures_util::StreamExt;
#[tokio::main]async fn main() -> anyhow::Result<()> { let gamma = GammaClient::new("https://gamma.openfish.fun"); let market_id = "abc123";
// Load existing comments via REST let existing = gamma.comments(market_id).await?; for c in &existing { println!("[history] {}: {}", c.author, c.body); }
// Stream new comments via WebSocket let mut ws = CommentSocket::connect("wss://gamma.openfish.fun/ws/comments").await?; ws.subscribe("market", market_id).await?;
while let Some(comment) = ws.next().await { println!("[live] {}: {}", comment.author, comment.body); }
Ok(())}Differences from CLOB WebSocket Channels
Section titled “Differences from CLOB WebSocket Channels”| Aspect | CLOB Channels (market, user, rtds, sports) | Comments Channel |
|---|---|---|
| Server | CLOB server (port 3002) | Gamma server |
| Base URL | wss://api.openfish.fun/ws/... | wss://gamma.openfish.fun/ws/comments |
| Auth required | Varies (user channel requires it) | No |
| Data type | Trading and price data | User-generated comments |
Next Steps
Section titled “Next Steps”- Market Channel — Order book and trade events.
- User Channel — Authenticated order updates.
- WebSocket Overview — All available channels.