🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@chainstream-io/sdk

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chainstream-io/sdk

API and Stream client for ChainStream

latest
Source
npmnpm
Version
2.1.26
Version published
Weekly downloads
870
Maintainers
1
Weekly downloads
 
Created
Source

ChainStream TypeScript SDK

Official TypeScript/JavaScript client library for ChainStream API.

Installation

npm install @chainstream-io/sdk
# or
pnpm add @chainstream-io/sdk
# or
yarn add @chainstream-io/sdk

Quick Start

import { ChainStreamClient } from '@chainstream-io/sdk';

// Create client
const client = new ChainStreamClient('your-access-token', {
  autoConnectWebSocket: false
});

// Subscribe to token stats via WebSocket
const unsubscribe = client.stream.subscribeTokenStats({
  chain: 'solana',
  tokenAddress: 'So11111111111111111111111111111111111111112',
  callback: (data) => {
    console.log('Token stats:', data);
  }
});

// Unsubscribe when done
unsubscribe.unsubscribe();

Batch subscribe token metrics

Ranking token metric list streams are deprecated and no longer published by the server. For ranking or new-pool cards, collect the token addresses first, then subscribe to per-token metric streams in one batch:

const unsubs = client.stream.batchSubscribe(() =>
  tokenAddresses.flatMap(tokenAddress => [
    client.stream.subscribeTokenStats({ chain: 'sol', tokenAddress, callback: onStats }),
    client.stream.subscribeTokenHolders({ chain: 'sol', tokenAddress, callback: onHolders }),
    client.stream.subscribeTokenSupply({ chain: 'sol', tokenAddress, callback: onSupply }),
    client.stream.subscribeTokenLiquidity({ chain: 'sol', tokenAddress, callback: onGeneralStat }),
  ]),
);

For new-pool experiences, subscribe with subscribeNewPool({ chain: 'sol' }), read the token address from the pool event, batch subscribe the token metrics above, and use subscribeDexPoolBalance for pool liquidity updates.

Prediction PNL realtime

Prediction PNL realtime uses compact wire fields, but the SDK callback maps them back to the same summary, dailyPnls, and changedTokens field names returned by GET /v1/prediction/wallets/{wallet}/pnl.

const wallet = '0x674f8fc1ee68c44e988e25316984cd7ea354ca64';
const tag = 'worldcup_2026';

const initial = await client.prediction.getPredictionWalletPnl(wallet, {
  tag,
  limit: 50,
  sort_by: 'totalPnl',
  order: 'desc',
});

renderPredictionPnl(initial.summary, initial.tokens);

const unsubscribeTag = client.stream.subscribePredictionWalletPnl({
  wallet,
  tag,
  callback: event => {
    renderPredictionPnlSummary(event.summary);
    mergeChangedTokens(event.changedTokens);
  },
});

const unsubscribeToken = client.stream.subscribePredictionWalletPnl({
  wallet,
  tokenId: '115556263888245616435851357148058235707004733438163639091106356867234218207169',
  callback: event => {
    mergeChangedTokens(event.changedTokens);
  },
});

Wallet-global prediction PNL channels are available through subscribePredictionWalletPnl({ wallet }), but the backend keeps them disabled by default to avoid unnecessary global aggregation and push load.

Features

  • REST API client generated from OpenAPI
  • WebSocket streaming for real-time data
  • Full TypeScript type definitions
  • Support for multiple subscription types:
    • Token stats, candles, holders
    • Wallet balances and PnL
    • Trade activities
    • Ranking lists
    • And more...

Documentation

For detailed documentation, visit https://docs.chainstream.io

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Generate OpenAPI client
pnpm orval

# Lint
pnpm lint

# Format
pnpm format

License

MIT

Keywords

chainstream

FAQs

Package last updated on 14 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts