### client.connect() Source: https://context7.com/polymarket/real-time-data-client/llms.txt Initiates the WebSocket connection to the configured host. It registers internal event handlers and starts the ping cycle once the socket is open. The `onConnect` callback is triggered after the socket opens. ```APIDOC ## client.connect() ### Description Initiates the WebSocket handshake to the configured host, registers all internal event handlers, and starts the ping cycle once the socket opens. Returns `this` to allow chaining. The `onConnect` callback fires after the socket opens. ### Method `connect()` ### Returns `this` (RealTimeDataClient instance) to allow chaining. ### Request Example ```typescript import { RealTimeDataClient, Message, ConnectionStatus } from "@polymarket/real-time-data-client"; const client = new RealTimeDataClient({ onStatusChange: (status: ConnectionStatus) => console.log("Status:", status), onConnect: (client: RealTimeDataClient) => { // Immediately subscribe after connection client.subscribe({ subscriptions: [{ topic: "activity", type: "trades" }], }); }, onMessage: (_client, message: Message) => { console.log(message.topic, message.type, message.timestamp, message.payload); }, }); client.connect(); // Status: CONNECTING → CONNECTED // Expected output when a trade occurs: // activity trades 1713000000000 { asset: "...", side: "BUY", price: 0.72, size: 100, ... } ``` ``` -------------------------------- ### Subscribe with ClobAuth Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Example of subscribing to topics using ClobAuth for authentication. ```APIDOC ## Subscribe with ClobAuth ### Description Subscribe to real-time data streams using ClobAuth credentials. ### Method `client.subscribe()` ### Parameters #### subscriptions - **topic** (string) - The topic to subscribe to (e.g., "clob_user") - **type** (string) - The type of subscription (e.g., "*") - **clob_auth** (ClobApiKeyCreds) - Authentication credentials for CLOB - **key** (string) - API key - **secret** (string) - API secret - **passphrase** (string) - API passphrase ### Request Example ```typescript client.subscribe({ subscriptions: [ { topic: "clob_user", type: "*", clob_auth: { key: "xxxxxx-xxxx-xxxxx-xxxx-xxxxxx", secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", passphrase: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", }, }, ], }); ``` ``` -------------------------------- ### Connect to Real-time Data Service Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Connect to the service and start receiving messages. Requires importing RealTimeDataClient and Message. The onMessage handler processes incoming messages, and the onConnect handler subscribes to topics upon successful connection. ```typescript import { RealTimeDataClient } from "../src/client"; import { Message } from "../src/model"; const onMessage = (message: Message): void => { console.log(message.topic, message.type, message.payload); }; const onConnect = (client: RealTimeDataClient): void => { // Subscribe to a topic client.subscribe({ subscriptions: [ { topic: "comments", type: "*", // "*" can be used to connect to all the types of the topic filters: `{"parentEntityID":100,"parentEntityType":"Event"}`, // empty means no filter }, ], }); }; new RealTimeDataClient({ onMessage, onConnect }).connect(); ``` -------------------------------- ### Close Connection - TypeScript Source: https://context7.com/polymarket/real-time-data-client/llms.txt Call `client.disconnect()` to disable automatic reconnection and close the WebSocket. This is for a controlled shutdown and the instance should not be reused afterward. The example demonstrates a graceful shutdown after 60 seconds. ```typescript import { RealTimeDataClient, Message, ConnectionStatus } from "@polymarket/real-time-data-client"; const client = new RealTimeDataClient({ onStatusChange: (status: ConnectionStatus) => { console.log("Status:", status); // Will print CONNECTING → CONNECTED → DISCONNECTED on shutdown }, onConnect: (c: RealTimeDataClient) => { c.subscribe({ subscriptions: [{ topic: "activity", type: "trades" }] }); // Gracefully shut down after 60 seconds setTimeout(() => { c.disconnect(); console.log("Disconnected cleanly — autoReconnect disabled"); }, 60_000); }, onMessage: (_c, message: Message) => { console.log(message.topic, message.payload); }, }); client.connect(); ``` -------------------------------- ### Message Interface and Payload Handling - TypeScript Source: https://context7.com/polymarket/real-time-data-client/llms.txt Incoming messages conform to the `Message` interface. The `payload` field requires casting to the appropriate domain type based on `topic` and `type`. This example shows handling 'trades', 'comment_created', and 'update' messages. ```typescript import { RealTimeDataClient, Message } from "@polymarket/real-time-data-client"; // Payload shapes by topic: interface Trade { asset: string; conditionId: string; eventSlug: string; slug: string; title: string; icon: string; outcome: string; outcomeIndex: number; price: number; size: number; side: "BUY" | "SELL"; timestamp: number; transactionHash: string; proxyWallet: string; name: string; pseudonym: string; bio: string; profileImage: string; } interface Comment { id: string; body: string; parentEntityType: string; parentEntityID: number; parentCommentID: string; userAddress: string; replyAddress: string; createdAt: string; updatedAt: string; } interface CryptoPrice { symbol: string; timestamp: number; value: number; } interface EquityPrice { symbol: string; timestamp: number; value: number; } const client = new RealTimeDataClient({ onConnect: (c) => { c.subscribe({ subscriptions: [ { topic: "activity", type: "trades" }, { topic: "comments", type: "comment_created" }, { topic: "crypto_prices", type: "update", filters: `{"symbol":"ETHUSDT"}` }, ]}); }, onMessage: (_c, message: Message) => { if (message.topic === "activity" && message.type === "trades") { const trade = message.payload as Trade; console.log(`${trade.side} ${trade.size} @ ${trade.price} — ${trade.title}`); // BUY 50 @ 0.65 — Will ETH hit $5,000 in 2025? } if (message.topic === "comments" && message.type === "comment_created") { const comment = message.payload as Comment; console.log(`New comment on event ${comment.parentEntityID}: "${comment.body}"`); } if (message.topic === "crypto_prices") { const price = message.payload as CryptoPrice; console.log(`${price.symbol}: $${price.value}`); // ETHUSDT: $3142.50 } }, }); client.connect(); ``` -------------------------------- ### Unsubscribe from Data Stream - TypeScript Source: https://context7.com/polymarket/real-time-data-client/llms.txt Use `client.unsubscribe()` to stop receiving messages for a specific topic/type. Other subscriptions on the same connection remain active. This example shows unsubscribing from 'trades' while keeping 'orders_matched'. ```typescript import { RealTimeDataClient, Message } from "@polymarket/real-time-data-client"; let client: RealTimeDataClient; client = new RealTimeDataClient({ onConnect: (c: RealTimeDataClient) => { // Subscribe to both trade types c.subscribe({ subscriptions: [ { topic: "activity", type: "trades" }, { topic: "activity", type: "orders_matched" }, ], }); // After 30 seconds, stop receiving trades but keep orders_matched setTimeout(() => { c.unsubscribe({ subscriptions: [{ topic: "activity", type: "trades" }], }); console.log("Unsubscribed from activity/trades"); }, 30_000); }, onMessage: (_c, message: Message) => { console.log(message.topic, message.type, message.payload); }, }); client.connect(); ``` -------------------------------- ### Instantiate RealTimeDataClient with Custom Arguments Source: https://context7.com/polymarket/real-time-data-client/llms.txt Instantiate the client with optional arguments to configure the host, ping interval, and reconnection behavior. Define callbacks for status changes, connection events, and message handling. ```typescript import { RealTimeDataClient, RealTimeDataClientArgs, Message, ConnectionStatus } from "@polymarket/real-time-data-client"; const args: RealTimeDataClientArgs = { host: "wss://ws-live-data.polymarket.com", // default; override for staging/local pingInterval: 5000, // ms between keepalive pings autoReconnect: true, // reconnect on drop or error onStatusChange: (status: ConnectionStatus) => { // ConnectionStatus: "CONNECTING" | "CONNECTED" | "DISCONNECTED" console.log("Connection status:", status); }, onConnect: (client: RealTimeDataClient) => { console.log("Connected — ready to subscribe"); }, onMessage: (client: RealTimeDataClient, message: Message) => { // message shape: { topic, type, timestamp, connection_id, payload } console.log(`[${message.topic}/${message.type}]`, message.payload); }, }; const client = new RealTimeDataClient(args); ``` -------------------------------- ### RealTimeDataClient Constructor Source: https://context7.com/polymarket/real-time-data-client/llms.txt Instantiates a new RealTimeDataClient. Optional arguments allow customization of the host, ping interval, reconnection behavior, and event callbacks for status changes, connection, and message handling. ```APIDOC ## new RealTimeDataClient(args?) ### Description Instantiates a new client. All fields in `RealTimeDataClientArgs` are optional; the client defaults to the production Polymarket WebSocket endpoint with a 5-second ping interval and automatic reconnection enabled. ### Parameters #### Optional Arguments (`RealTimeDataClientArgs`) - **host** (string) - The WebSocket endpoint URL. Defaults to `wss://ws-live-data.polymarket.com`. - **pingInterval** (number) - The interval in milliseconds between keepalive pings. Defaults to 5000. - **autoReconnect** (boolean) - Whether to automatically reconnect on connection drops or errors. Defaults to true. - **onStatusChange** (function) - Callback function that receives connection status updates (`CONNECTING`, `CONNECTED`, `DISCONNECTED`). - **onConnect** (function) - Callback function invoked after a successful connection is established. - **onMessage** (function) - Callback function that receives incoming messages. The message object has `topic`, `type`, `timestamp`, `connection_id`, and `payload` fields. ### Request Example ```typescript import { RealTimeDataClient, RealTimeDataClientArgs, Message, ConnectionStatus } from "@polymarket/real-time-data-client"; const args: RealTimeDataClientArgs = { host: "wss://ws-live-data.polymarket.com", // default; override for staging/local pingInterval: 5000, // ms between keepalive pings autoReconnect: true, // reconnect on drop or error onStatusChange: (status: ConnectionStatus) => { // ConnectionStatus: "CONNECTING" | "CONNECTED" | "DISCONNECTED" console.log("Connection status:", status); }, onConnect: (client: RealTimeDataClient) => { console.log("Connected — ready to subscribe"); }, onMessage: (client: RealTimeDataClient, message: Message) => { // message shape: { topic, type, timestamp, connection_id, payload } console.log(`[${message.topic}/${message.type}]`, message.payload); }, }; const client = new RealTimeDataClient(args); ``` ``` -------------------------------- ### Subscribe to Trade Activity, Comments, and Price Feeds Source: https://context7.com/polymarket/real-time-data-client/llms.txt Use this snippet to subscribe to various data streams like trade activity, comments, crypto prices, equity prices, and CLOB market data. Ensure the socket is open before subscribing. Multiple subscriptions can be made in a single call. ```typescript import { RealTimeDataClient, Message } from "@polymarket/real-time-data-client"; const client = new RealTimeDataClient({ onConnect: (client: RealTimeDataClient) => { // 1. Trade activity filtered to a specific event client.subscribe({ subscriptions: [{ topic: "activity", type: "trades", filters: `{"event_slug":"super-bowl-2025-winner"}`, }], }); // 2. All comment events on event ID 100 client.subscribe({ subscriptions: [{ topic: "comments", type: "*", // wildcard — receives comment_created, comment_removed, reaction_created, reaction_removed filters: `{"parentEntityID":100,"parentEntityType":"Event"}`, }], }); // 3. Bitcoin price feed (spot); server sends a historical snapshot on connect, then live updates client.subscribe({ subscriptions: [{ topic: "crypto_prices", type: "update", filters: `{"symbol":"BTCUSDT"}`, }], }); // 4. Apple equity price feed client.subscribe({ subscriptions: [{ topic: "equity_prices", type: "update", filters: `{"symbol":"AAPL"}`, }], }); // 5. CLOB order-book for a specific market (no auth required) client.subscribe({ subscriptions: [{ topic: "clob_market", type: "*", filters: `["71321045679252212594626385532706912750332728571942532289631379312455583992563"]`, }], }); }, onMessage: (_client, message: Message) => { // All subscribed topics funnel into this single handler switch (message.topic) { case "crypto_prices": const { symbol, value, timestamp } = message.payload as { symbol: string; value: number; timestamp: number }; console.log(`BTC: $${value} at ${new Date(timestamp).toISOString()}`); break; case "equity_prices": console.log("Equity update:", message.payload); break; default: console.log(message.topic, message.type, message.payload); } }, }); client.connect(); ``` -------------------------------- ### Connect and Subscribe to Trades Source: https://context7.com/polymarket/real-time-data-client/llms.txt Initiate the WebSocket connection and immediately subscribe to trade activity after the connection is established. Handles connection status changes and logs incoming messages. ```typescript import { RealTimeDataClient, Message, ConnectionStatus } from "@polymarket/real-time-data-client"; const client = new RealTimeDataClient({ onStatusChange: (status: ConnectionStatus) => console.log("Status:", status), onConnect: (client: RealTimeDataClient) => { // Immediately subscribe after connection client.subscribe({ subscriptions: [{ topic: "activity", type: "trades" }], }); }, onMessage: (_client, message: Message) => { console.log(message.topic, message.type, message.timestamp, message.payload); }, }); client.connect(); // Status: CONNECTING → CONNECTED // Expected output when a trade occurs: // activity trades 1713000000000 { asset: "...", side: "BUY", price: 0.72, size: 100, ... } ``` -------------------------------- ### client.subscribe(msg) with `clob_auth` — Authenticated CLOB User Stream Source: https://context7.com/polymarket/real-time-data-client/llms.txt Subscribing to the `clob_user` topic requires CLOB API key credentials passed inline on the subscription. The server validates the credentials and streams user-specific order and fill events. ```APIDOC ## `client.subscribe(msg)` with `clob_auth` — Authenticated CLOB User Stream ### Description Subscribing to the `clob_user` topic requires CLOB API key credentials passed inline on the subscription. The server validates the credentials and streams user-specific order and fill events. ### Method Signature `client.subscribe(msg: { subscriptions: Array<{ topic: string; type: string; clob_auth?: ClobApiKeyCreds }> })` ### Parameters #### `msg` Object - **subscriptions** (Array) - Required - An array of subscription objects. - **topic** (string) - Required - Must be "clob_user". - **type** (string) - Required - Typically "*". - **clob_auth** (Object) - Required - An object containing CLOB API key credentials. - **key** (string) - Required - Your CLOB API key. - **secret** (string) - Required - Your CLOB API secret. - **passphrase** (string) - Required - Your CLOB API passphrase. ### Request Example ```typescript const clobAuth = { key: process.env.CLOB_API_KEY!, secret: process.env.CLOB_API_SECRET!, passphrase: process.env.CLOB_API_PASSPHRASE!, }; client.subscribe({ subscriptions: [{ topic: "clob_user", type: "*", clob_auth: clobAuth, }], }); ``` ### Response When subscribing to `clob_user`, the `onMessage` handler will receive user-specific order and fill events. The `message.payload` will contain details about orders, fills, and cancellations. ``` -------------------------------- ### Track Connection Status with RealTimeDataClient Source: https://context7.com/polymarket/real-time-data-client/llms.txt Use the `onStatusChange` callback to monitor connection lifecycle transitions and drive UI indicators or alerts. The `ConnectionStatus` enum provides states like CONNECTING, CONNECTED, and DISCONNECTED. ```typescript import { RealTimeDataClient, ConnectionStatus } from "@polymarket/real-time-data-client"; let reconnectCount = 0; const client = new RealTimeDataClient({ autoReconnect: true, onStatusChange: (status: ConnectionStatus) => { switch (status) { case ConnectionStatus.CONNECTING: console.log(`Connecting… (attempt ${++reconnectCount})`); break; case ConnectionStatus.CONNECTED: console.log("Connected"); reconnectCount = 0; break; case ConnectionStatus.DISCONNECTED: console.warn("Disconnected — autoReconnect will retry"); break; } }, onConnect: (c) => { c.subscribe({ subscriptions: [{ topic: "activity", type: "*" }] }); }, onMessage: (_c, msg) => console.log(msg.topic, msg.type), }); client.connect(); ``` -------------------------------- ### Subscribe to Authenticated CLOB User Stream Source: https://context7.com/polymarket/real-time-data-client/llms.txt Subscribe to the `clob_user` topic to receive user-specific order and fill events. This requires CLOB API key credentials to be passed inline on the subscription. Ensure your API keys are securely stored and accessed. ```typescript import { RealTimeDataClient, Message, ClobApiKeyCreds } from "@polymarket/real-time-data-client"; const clobAuth: ClobApiKeyCreds = { key: process.env.CLOB_API_KEY!, secret: process.env.CLOB_API_SECRET!, passphrase: process.env.CLOB_API_PASSPHRASE!, }; const client = new RealTimeDataClient({ onConnect: (client: RealTimeDataClient) => { client.subscribe({ subscriptions: [{ topic: "clob_user", type: "*", clob_auth: clobAuth, }], }); }, onMessage: (_client, message: Message) => { if (message.topic === "clob_user") { console.log("User order event:", message.type, message.payload); // Expected payload fields include order details, fills, cancellations } }, }); client.connect(); ``` -------------------------------- ### client.subscribe(msg) — Subscribe to a Data Stream Source: https://context7.com/polymarket/real-time-data-client/llms.txt Sends an 'subscribe' frame over the open socket for one or more topic/type pairs. This method allows subscribing to various data streams like trade activity, comments, crypto prices, equity prices, and CLOB order books. ```APIDOC ## `client.subscribe(msg)` — Subscribe to a Data Stream ### Description Sends an `action: "subscribe"` frame over the open socket for one or more topic/type pairs in a single call. Multiple `subscribe` calls can be made over the same connection at any time. If the socket is not open a warning is logged and no message is sent. ### Method Signature `client.subscribe(msg: { subscriptions: Array<{ topic: string; type: string; filters?: string; }> })` ### Parameters #### `msg` Object - **subscriptions** (Array) - Required - An array of subscription objects. - **topic** (string) - Required - The topic to subscribe to (e.g., "activity", "comments", "crypto_prices", "equity_prices", "clob_market"). - **type** (string) - Required - The type of data within the topic (e.g., "trades", "*", "update"). - **filters** (string) - Optional - A JSON string representing filters for the subscription. ### Request Example ```typescript client.subscribe({ subscriptions: [ { topic: "activity", type: "trades", filters: `{"event_slug":"super-bowl-2025-winner"}`, }, { topic: "comments", type: "*", filters: `{"parentEntityID":100,"parentEntityType":"Event"}`, }, { topic: "crypto_prices", type: "update", filters: `{"symbol":"BTCUSDT"}`, }, { topic: "equity_prices", type: "update", filters: `{"symbol":"AAPL"}`, }, { topic: "clob_market", type: "*", filters: `["71321045679252212594626385532706912750332728571942532289631379312455583992563"]`, } ], }); ``` ### Response All subscribed topics funnel into the `onMessage` handler. The structure of the `message.payload` depends on the subscribed topic and type. ``` -------------------------------- ### Subscribe to Clob User Data Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Subscribes to 'clob_user' topic with specified authentication credentials. Replace placeholder values with actual API key, secret, and passphrase. ```typescript client.subscribe({ subscriptions: [ { topic: "clob_user", type: "*", clob_auth: { key: "xxxxxx-xxxx-xxxxx-xxxx-xxxxxx", secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", passphrase: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", }, }, ], }); ``` -------------------------------- ### Subscribe to Activity Trades Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Subscribe to 'trades' messages from the 'activity' topic. This is done after the client has successfully connected. ```typescript client.subscribe({ subscriptions: [ { topic: "activity", type: "trades", }, ], }); ``` -------------------------------- ### Subscribe to All Comments Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Subscribe to all types of messages within the 'comments' topic using the wildcard '*'. This is useful for receiving all comment-related updates. ```typescript client.subscribe({ subscriptions: [ { topic: "comments", type: "*", // "*" can be used to connect to all the types of the topic }, ], }); ``` -------------------------------- ### ClobAuth Credentials Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Defines the structure for API key credentials used in CLOB authentication. ```APIDOC ## ClobApiKeyCreds ### Description API key credentials for CLOB authentication. ### Fields - **key** (string) - API key used for authentication - **secret** (string) - API secret associated with the key - **passphrase** (string) - Passphrase required for authentication ``` -------------------------------- ### client.unsubscribe(msg) Source: https://context7.com/polymarket/real-time-data-client/llms.txt Sends an action: "unsubscribe" frame to stop receiving messages for a specific topic/type combination. Other active subscriptions on the same connection are unaffected. Unsubscribing from a wildcard-subscribed topic by a specific type removes only that type. ```APIDOC ## `client.unsubscribe(msg)` — Unsubscribe from a Data Stream ### Description Sends an `action: "unsubscribe"` frame to stop receiving messages for a specific topic/type combination. Other active subscriptions on the same connection are unaffected. Unsubscribing from a wildcard-subscribed topic by a specific type removes only that type. ### Parameters #### Request Body - **subscriptions** (array) - Required - An array of subscription objects to unsubscribe from. - **topic** (string) - Required - The topic of the subscription. - **type** (string) - Required - The type of the subscription. ### Request Example ```json { "action": "unsubscribe", "subscriptions": [ { "topic": "activity", "type": "trades" }, { "topic": "activity", "type": "orders_matched" } ] } ``` ``` -------------------------------- ### Message Interface Source: https://context7.com/polymarket/real-time-data-client/llms.txt Every message delivered to the onMessage callback conforms to the Message interface. The payload field is typed as object and should be cast to the appropriate domain type based on topic and type. ```APIDOC ## `Message` Interface — Incoming Message Shape ### Description Every message delivered to the `onMessage` callback conforms to the `Message` interface. The `payload` field is typed as `object` and should be cast to the appropriate domain type based on `topic` and `type`. ### Interface Definition ```typescript interface Message { topic: string; type: string; payload: object; } ``` ### Payload Shapes by Topic: #### Trade ```typescript interface Trade { asset: string; conditionId: string; eventSlug: string; slug: string; title: string; icon: string; outcome: string; outcomeIndex: number; price: number; size: number; side: "BUY" | "SELL"; timestamp: number; transactionHash: string; proxyWallet: string; name: string; pseudonym: string; bio: string; profileImage: string; } ``` #### Comment ```typescript interface Comment { id: string; body: string; parentEntityType: string; parentEntityID: number; parentCommentID: string; userAddress: string; replyAddress: string; createdAt: string; updatedAt: string; } ``` #### CryptoPrice ```typescript interface CryptoPrice { symbol: string; timestamp: number; value: number; } ``` #### EquityPrice ```typescript interface EquityPrice { symbol: string; timestamp: number; value: number; } ``` ``` -------------------------------- ### CryptoPrice Message Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Details of the 'CryptoPrice' message type. ```APIDOC ## CryptoPrice ### Description Provides real-time price updates for cryptocurrencies. ### Fields - **symbol** (string) - Symbol of the asset - **timestamp** (number) - Timestamp in milliseconds for the update - **value** (number) - Value at the time of update ### Filters - `{"symbol":"BTCUSDT"}` - `{"symbol":"ETHUSDT"}` - `{"symbol":"XRPUSDT"}` - `{"symbol":"SOLUSDT"}` - `{"symbol":"DOGEUSDT"}` ``` -------------------------------- ### EquityPrice Message Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Details of the 'EquityPrice' message type. ```APIDOC ## EquityPrice ### Description Provides real-time price updates for equities. ### Fields - **symbol** (string) - Symbol of the asset - **timestamp** (number) - Timestamp in milliseconds for the update - **value** (number) - Value at the time of update ``` -------------------------------- ### client.disconnect() Source: https://context7.com/polymarket/real-time-data-client/llms.txt Disables automatic reconnection and closes the underlying WebSocket. Use this for a controlled shutdown. After calling disconnect(), the instance should not be reused. ```APIDOC ## `client.disconnect()` — Close the Connection ### Description Disables automatic reconnection and closes the underlying WebSocket. Use this for a controlled shutdown. After calling `disconnect()`, the instance should not be reused. ### Method `disconnect()` ### Endpoint N/A (Client-side method) ### Parameters None ``` -------------------------------- ### Define ClobApiKeyCreds Interface Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Defines the structure for API key credentials used in CLOB authentication. Ensure all fields (key, secret, passphrase) are provided. ```typescript /** * API key credentials for CLOB authentication. */ export interface ClobApiKeyCreds { /** API key used for authentication */ key: string; /** API secret associated with the key */ secret: string; /** Passphrase required for authentication */ passphrase: string; } ``` -------------------------------- ### Activity Trade Message Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Details of the 'Trade' activity message type. ```APIDOC ## Activity Trade ### Description Represents a trade activity in the system. ### Fields - **asset** (string) - ERC1155 token ID of conditional token being traded - **bio** (string) - Bio of the user of the trade - **conditionId** (string) - Id of market which is also the CTF condition ID - **eventSlug** (string) - Slug of the event - **icon** (string) - URL to the market icon image - **name** (string) - Name of the user of the trade - **outcome** (string) - Human readable outcome of the market - **outcomeIndex** (integer) - Index of the outcome - **price** (float) - Price of the trade - **profileImage** (string) - URL to the user profile image - **proxyWallet** (string) - Address of the user proxy wallet - **pseudonym** (string) - Pseudonym of the user - **side** (string) - Side of the trade (`BUY`/`SELL`) - **size** (integer) - Size of the trade - **slug** (string) - Slug of the market - **timestamp** (integer) - Timestamp of the trade - **title** (string) - Title of the event - **transactionHash** (string) - Hash of the transaction ``` -------------------------------- ### Disconnect from WebSocket Service Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Disconnects the client from the WebSocket server. This should be called when the client is no longer needed to free up resources. ```typescript client.disconnect(); ``` -------------------------------- ### Comments Reaction Message Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Details of the 'Reaction' message type within the Comments section. ```APIDOC ## Comments Reaction ### Description Represents a reaction to a comment. ### Fields - **id** (string) - Unique identifier of reaction - **commentID** (number) - ID of the comment - **reactionType** (string) - Type of the reaction - **icon** (string) - Icon representing the reaction - **userAddress** (string) - Address of the user - **createdAt** (string) - Creation timestamp ``` -------------------------------- ### Comments Comment Message Source: https://github.com/polymarket/real-time-data-client/blob/main/README.md Details of the 'Comment' message type within the Comments section. ```APIDOC ## Comments Comment ### Description Represents a comment entity. ### Fields - **id** (string) - Unique identifier of comment - **body** (string) - Content of the comment - **parentEntityType** (string) - Type of the parent entity (Event or Series) - **parentEntityID** (number) - ID of the parent entity - **parentCommentID** (string) - ID of the parent comment - **userAddress** (string) - Address of the user - **replyAddress** (string) - Address of the reply user - **createdAt** (string) - Creation timestamp - **updatedAt** (string) - Last update timestamp ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.