This document describes the WebSocket subscription methods provided by the ChainStream JavaScript SDK. Each method is a wrapper for the corresponding WebSocket API. For detailed parameter descriptions and return value structures, please click the corresponding API link.

Candles

Token

Ranking

Wallet

Trade

DexPool

Connection Management

Establish Connection

client.stream.connect()
All subscription methods return an Unsubscrible object that can be used to cancel subscriptions:
const subscription = client.stream.subscribeTokenCandles(/* ... */);
// Cancel subscription
subscription.unsubscribe();

Batch Subscription

Batch subscribe to multiple data streams

Usage Example

const unsubscribles = client.stream.batchSubscribe(() => [
  client.stream.subscribeWalletBalance({
    chain: 'sol',
    walletAddress: "wallet address 1",
    callback: (data: WalletBalance[]) => {
        // todo
    }
  }),
  
  client.stream.subscribeWalletBalance({
    chain: 'sol',
    walletAddress: "wallet address 2",
    callback: (data: WalletBalance[]) => {
        // todo
    }
  })
]);
For detailed parameter descriptions, data formats, and error handling, please refer to the WebSocket API Documentation.