# Reduce REST polling in a trading terminal

Share a MadeOnSol stream across terminal panels, initialise each token view once and refresh only data that has changed.

Access: Pro and above · channel access varies

[Compare plans and subscribe](https://madeonsol.com/pricing#pricing)

## Integration choice

When two viewers open the same token, attach both to the same upstream subscription. Keep distinct subscriptions for different chains or filters. Refresh snapshot-only panels according to their own freshness target.

## Implementation steps

1. Keep one upstream stream on your backend and share it across viewers where your display licence permits it. Key subscriptions and cached snapshots by chain, address and requested modules. Reference-count them so closing one tab does not interrupt another.
2. Subscribe first and wait for acknowledgement. Buffer arriving events while loading the baseline. The helper examples below coordinate the snapshot and stream for each panel. Request only the modules the panel actually renders.
3. Use pushed state where available. For snapshot-only data, set a freshness target and coalesce reads across viewers. When the last viewer leaves, release the subscription. Treat recovery of event history separately from refreshing current state.
4. Measure requests per active token, upstream sockets, inbound bytes and time to first populated panel. Compare the same watchlist and session duration before and after enabling streaming.

## Solana backend

~~~javascript
// Node 22+, server side: the msk_ key never leaves your backend.
import { MadeOnSolREST } from "madeonsol-x402";

const client = new MadeOnSolREST({ apiKey: process.env.MADEONSOL_API_KEY });
const stream = client.stream(); // ONE shared socket for every panel

const mint = process.env.SOLANA_MINT;
const view = client.watchTokenIntelligence(mint, {
  stream,
  subId: "panel_main",              // unique per panel on this socket; "default" is refused
  tier: "PRO",                      // your plan; the server stays authoritative
  include: ["snapshot", "risk", "holder_count", "locks"], // cost 2 + 2 + 1 + 1 = 6 (max 8, max 5 modules)
  includeKolBroadcast: false,       // true = the whole KOL roster broadcast on this socket
  debounceMs: 750,
  minModuleRefreshMs: 15_000,
  onChange(v) {
    // v.phase: awaiting_subscribe | bootstrapping | live | degraded | stopped
    for (const [name, m] of Object.entries(v.snapshot?.modules ?? {})) {
      console.log(name, m.status, m.reason, m.as_of);
    }
    if (v.stale.length) console.log("refreshing", v.stale);
    if (v.incomplete) console.log("history may be incomplete; do not imply missed trades were recovered");
  },
  onLive(frame, module) {
    if (module === "snapshot") console.log("price overlay", frame.data);
  },
});

process.once("SIGINT", () => { view.dispose(); stream.close(); });
~~~

## Robinhood Chain backend

~~~javascript
// Node 22+, server side. Key mode only: a keyless x402 client throws
// token_intelligence_requires_api_key.
import { RobinhoodChainX402 } from "robinhood-chain-x402";

const client = new RobinhoodChainX402({ apiKey: process.env.MADEONSOL_API_KEY });
const stream = client.stream();

const address = process.env.RHC_TOKEN_ADDRESS; // 0x..., compared case-insensitively
const view = client.watchTokenIntelligence(address, {
  stream,
  subId: "rhc_panel_main",
  tier: "ULTRA",
  include: ["snapshot", "risk", "flow"], // cost 2 + 2 + 3 = 7
  // Ultra+ only. rhc:dex_trades is NOT address-filtered by the server: you
  // receive the whole attributed RHC tape and the helper filters client-side.
  // Leave it off and flow refreshes on rhc:token_candles instead.
  includeRhcFirehose: false,
  onChange(v) {
    const flow = v.snapshot?.modules.flow;
    console.log(v.phase, flow?.status, flow?.reason); // e.g. partial_history / history_not_verified
  },
  onLive(frame, module) {
    if (module === "snapshot") console.log("price overlay", frame.data);
  },
});

process.once("SIGINT", () => { view.dispose(); stream.close(); });
~~~

![MadeOnSol terminal showing DEET on Solana with a one-minute price chart and a table of recent trades.](https://madeonsol.com/guides/terminal-overview.jpg)

The chart and trade tape show the same token. Use the second-tab test below to verify that viewers share the upstream connection.

## Verify your integration

Open the same token in a second tab. The upstream socket count should stay flat. Close one tab and check the other still updates. Compare REST calls per token and time to first populated panel for the same watchlist.

## Related reference

- [Terminal helper reference](https://madeonsol.com/api-docs#terminal-helper)
- [Live terminal demo](https://madeonsol.com/terminal-demo)
- [Terms and display rights](https://madeonsol.com/terms)

[Canonical guide](https://madeonsol.com/docs/terminal)
