How to Stream Real-Time Solana DEX Trades with WebSockets

Build a Solana DEX trade monitor on MadeOnSol's filtered WebSocket firehose. Covers the current permanent stream-token flow, 14 decoded programs across 8 venues, named subscriptions, replay, and production reconnects.

MadeOnSol··Updated · 9 min read
How to Stream Real-Time Solana DEX Trades with WebSockets

Disclosure: This article contains affiliate links. If you sign up through them, MadeOnSol may earn a commission at no extra cost to you. This never affects our rankings, ratings, or reviews.

MadeOnSol's DEX firehose is a filtered WebSocket view of parsed Solana swaps. It currently decodes 14 program IDs across 8 venues — Pump.fun, PumpSwap, Raydium, Jupiter, Orca, Meteora, LaunchLab and Moonshot — so a client can consume normalized trade frames without running Yellowstone or maintaining a parser per venue.

Updated September 2026: this tutorial now matches the live firehose protocol. Stream tokens no longer expire, the socket must be authenticated with the stream token, trade frames use channel: "dex:trades", ULTRA and BUSINESS have DEX-firehose slots, and the service supports named subscriptions plus bounded replay.

What you'll build

A TypeScript process that:

  1. fetches the account's permanent stream token;
  2. authenticates wss://madeonsol.com/ws/v1/dex-stream;
  3. creates a named, filtered subscription;
  4. consumes dex:trades frames;
  5. reconnects safely when the socket drops.

Prerequisites

  • Node.js 18+
  • an authenticated MadeOnSol API key
  • an ULTRA or BUSINESS-class plan for the Solana DEX firehose
  • basic TypeScript/WebSocket knowledge

PRO has the main signal WebSocket but no DEX-firehose connection slots. ULTRA has 2 DEX connections; BUSINESS has 5. Enterprise inherits at least the Business floor unless its contract says otherwise.

Coverage: 14 programs, 8 venues

The canonical decoder registry currently covers:

  • Pump.fun
  • PumpSwap
  • Raydium AMM v4
  • Raydium CPMM
  • Raydium CLMM
  • Raydium Route
  • Jupiter
  • Orca Whirlpool
  • Meteora DBC
  • Meteora DLMM
  • Meteora DAMM
  • Meteora CPAMM
  • Raydium LaunchLab
  • Moonshot

The important distinction is programs versus venues: several Raydium and Meteora program IDs roll up to the same venue name.

Step 1: get a stream token

The REST endpoint uses your normal msk_ API key:

import { MadeOnSol } from "madeonsol";

const client = new MadeOnSol({
  apiKey: process.env.MADEONSOL_API_KEY!,
});

const stream = await client.stream.getToken();

console.log(stream.ws_url);
console.log(stream.dex_ws_url);
console.log(stream.expires_at); // null

Current stream-token behavior:

  • expires_at is null;
  • next_refresh_at is null;
  • calling the endpoint again normally returns the same token;
  • the token stops working if streaming entitlement lapses or it is explicitly rotated;
  • POST /api/v1/stream/token {"rotate":true} replaces it, with 60 seconds of grace for the previous value.

Do not implement the retired 24-hour refresh timer.

Step 2: connect with the token

The DEX socket does not accept your msk_ API key as WebSocket auth. It accepts the stream token returned above.

For Node's ws package, prefer the Authorization header:

import WebSocket from "ws";

const { token, dex_ws_url } = await client.stream.getToken();

if (!dex_ws_url) {
  throw new Error("DEX stream requires an ULTRA-class plan");
}

const ws = new WebSocket(dex_ws_url, {
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

The query-string form also works:

const ws = new WebSocket(
  `${dex_ws_url}?token=${encodeURIComponent(token)}`
);

Step 3: create a filtered subscription

The firehose requires at least one targeting filter. A named subscription is useful because you can run several independent views on one socket.

ws.on("open", () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    sub_id: "pumpfun-large-buys",
    filters: {
      dex: "pumpfun",
      min_sol: 1,
      action: "buy"
    },
    replay: 50
  }));
});

The service caps one socket at 10 subscriptions. If you omit sub_id, the subscription is named default.

Useful trade filters include:

FilterMeaning
token_mintone mint
token_mintsup to 50 mints
walletone trader wallet
walletsup to 50 wallets
dexvenue name
programexact decoded program ID
min_sol / max_solSOL-size bounds
actionbuy or sell

Filters on the same subscription are ANDed.

Step 4: consume the actual wire frame

A normal trade is delivered under the dex:trades channel:

{
  "channel": "dex:trades",
  "sub_id": "pumpfun-large-buys",
  "data": {
    "wallet": "7xKX...",
    "mint": "DezX...",
    "action": "buy",
    "sol_amount": 2.5,
    "token_amount": 1500000,
    "tx_signature": "5xYz...",
    "block_time": "2026-09-29T20:30:15Z",
    "slot": 312456789,
    "program": "6EF8...",
    "dex": "pumpfun",
    "executed_price_sol": 0.00000167,
    "pool_address": "...",
    "pool_model": "bonding_curve",
    "dust": false
  },
  "ts": 1790713815000
}

The frame intentionally does not promise token names or symbols. Resolve metadata separately and cache it.

A minimal handler:

ws.on("message", (raw) => {
  const msg = JSON.parse(raw.toString());

  if (msg.type === "heartbeat") return;
  if (msg.type === "subscribed") {
    console.log("subscription accepted:", msg.sub_id);
    return;
  }
  if (msg.type === "replay_done") {
    console.log("replay finished:", msg.sub_id, msg.sent);
    return;
  }

  if (msg.channel !== "dex:trades") return;

  const trade = msg.data;
  console.log(
    `[${trade.dex}] ${trade.action} ${trade.mint.slice(0, 8)}… — ${trade.sol_amount} SOL`
  );
});

Step 5: track several strategies on one socket

Do not repeatedly overwrite one anonymous filter when you actually want independent views. Use distinct sub_id values:

ws.send(JSON.stringify({
  type: "subscribe",
  sub_id: "mint-watch",
  filters: {
    token_mints: watchedMints
  }
}));

ws.send(JSON.stringify({
  type: "subscribe",
  sub_id: "pumpfun-size",
  filters: {
    dex: "pumpfun",
    min_sol: 2
  }
}));

ws.send(JSON.stringify({
  type: "subscribe",
  sub_id: "wallet-watch",
  filters: {
    wallets: watchedWallets
  }
}));

Every delivered frame carries the matching sub_id, so dedupe keys should include the subscription identity when the same trade intentionally matches more than one view.

The service also supports updating, listing and removing named subscriptions. Keep your desired subscription set in application state so you can recreate it after reconnect.

Building a product on Solana or Robinhood Chain data?

Skip the Geyser pipeline — embed KOL flow, deployer reputation, and the all-DEX firehose over REST, WebSocket, or webhooks. The Business tier (€400/mo) is the self-serve embed license at 500k calls/day — Enterprise adds white-label & redistribution.

See Business pricing

Step 6: use replay for short disconnects

The DEX stream keeps an in-memory replay buffer. On subscribe, replay: N asks for recent matching frames, up to the server cap of 500.

ws.send(JSON.stringify({
  type: "subscribe",
  sub_id: "mint-watch",
  filters: {
    token_mints: watchedMints
  },
  replay: 100
}));

The server finishes with a replay_done frame describing how many matching frames were sent and whether the replay was complete.

Replay is a recovery aid, not a historical database. If your application needs durable trade history beyond the in-memory window, store the events you consume or use the relevant REST/history surface.

Step 7: build a production reconnect loop

The token is permanent; the socket is not. Reconnect after network failures and server restarts, and back off when the server tells you the connection limit is full.

import WebSocket from "ws";
import { MadeOnSol } from "madeonsol";

const client = new MadeOnSol({
  apiKey: process.env.MADEONSOL_API_KEY!,
});

const desiredSubscriptions = [
  {
    type: "subscribe",
    sub_id: "pumpfun-large-buys",
    filters: { dex: "pumpfun", min_sol: 1, action: "buy" },
    replay: 100,
  },
];

async function runForever() {
  let backoff = 2_000;

  for (;;) {
    try {
      const { token, dex_ws_url } = await client.stream.getToken();
      if (!dex_ws_url) throw new Error("No DEX stream entitlement");

      await new Promise<void>((resolve, reject) => {
        const ws = new WebSocket(dex_ws_url, {
          headers: { Authorization: `Bearer ${token}` },
        });

        ws.on("open", () => {
          for (const sub of desiredSubscriptions) {
            ws.send(JSON.stringify(sub));
          }
        });

        ws.on("message", (raw) => {
          const msg = JSON.parse(raw.toString());

          if (msg.type === "subscribed") {
            backoff = 2_000;
            return;
          }

          if (msg.channel === "dex:trades") {
            onTrade(msg.sub_id, msg.data);
          }
        });

        ws.on("close", (code, reason) => {
          reject(Object.assign(
            new Error(`DEX socket closed ${code}: ${reason.toString()}`),
            { code }
          ));
        });

        ws.on("error", reject);
      });
    } catch (err: any) {
      if (Number(err?.code) === 4002) {
        backoff = Math.max(backoff, 60_000);
      } else {
        backoff = Math.min(Math.round(backoff * 1.5), 60_000);
      }

      await new Promise((r) => setTimeout(r, backoff));
    }
  }
}

Resetting backoff after a successful subscription acknowledgement is safer than resetting it on TCP open: a socket that opens but cannot subscribe is not healthy.

Step 8: combine the firehose with intelligence APIs

The firehose answers "what trade just happened?" It intentionally does not recompute every higher-order signal in the hot path.

A common architecture is:

DEX firehose
   ↓
cheap local filters
   ↓
interesting mint
   ↓
POST /api/v1/token/batch
or buyer-quality / deployer / KOL endpoints
   ↓
strategy decision

If several new mints arrive together, use the batch endpoints rather than issuing one REST call per mint. The batch-token guide explains the 50-mint request shape and the quota implications.

Optional views: route legs and liquidity events

The DEX stream has grown beyond the legacy one-trade-per-transaction frame.

For applications that need execution-path detail, subscriptions can opt into route/leg frames. For liquidity monitoring, liquidity: true adds dex:liquidity events and liquidity: "only" creates a liquidity-only subscription.

These are additive views of the same decoded transaction, not extra trades. If you use them for volume analytics, do not add leg events and the legacy dex:trades frame together or you will double-count the transaction.

Current plan limits

FeaturePROULTRABUSINESS
Main signal WebSocket connections2310
Solana DEX firehose connections025
REST requests/day10,000100,000500,000
Generic webhooks31030

The Free/BASIC plan has 200 REST requests/day but no paid WebSocket connection slot.

See the live pricing page for the current plan presentation.

FAQ

Does the firehose include every Solana transaction?

No. It is a DEX trade stream over the decoded program registry, not a general-purpose Solana transaction feed. The current registry is 14 program IDs across 8 venues.

Is the stream confirmed or processed?

Treat the firehose as a low-latency live feed rather than a finality guarantee. Strategy code that moves money should define its own confirmation/finality policy instead of inferring it from a marketing latency number.

Can I subscribe to several filters at once?

Yes. Use named subscriptions (sub_id) when the views are independent. One connection can hold up to 10 DEX subscriptions. A single subscription can also combine several filters, which are evaluated together.

Does the stream include symbols and names?

No guarantee. The stable trade identity is the mint address. Resolve display metadata separately and cache it.

Do I need to refresh the stream token every 24 hours?

No. That behavior was retired on August 27, 2026. The token has no scheduled expiry; reconnect the socket when necessary and fetch the current token again during reconnect.

Resources

The production rule is simple: authenticate with the stream token, subscribe narrowly, treat the wire schema as the contract, and make reconnect/replay part of the client from day one.

Tools mentioned

Compare features and read reviews.

Live health scores, average ratings, and direct links on MadeOnSol.

Build a deployer sniper bot

Access deployer alerts, bonding stats, and tier data via API. Free tier: 200 requests/day.

Start free
import { MadeOnSol } from "madeonsol";

const client = new MadeOnSol({ apiKey: "msk_your_key" });

// Elite deployer alerts with KOL buy enrichment
const { alerts } = await client.deployer.alerts({ limit: 5 });

// Top deployers by bonding rate
const { deployers } = await client.deployer.leaderboard({ tier: "elite" });
npm install madeonsolFull API docs

Building a product on Solana or Robinhood Chain data?

MadeOnSol isn't an RPC or another generic token API — it's Solana & Robinhood Chain memecoin intelligence that's painful to build in-house, pulled from dual-region gRPC shred streams and our own Robinhood Chain node, pushed to your app as events land.

Signals you'd otherwise build

KOL & smart-money flow from 2,000+ labeled wallets, deployer reputation, coordination clusters, linked-wallet entity resolution, and an all-DEX firehose.

Embed it in your product

The Business tier (€400/mo, self-serve) licenses you to display MadeOnSol data inside your own product — 500k calls/day, 15 WS + 6 firehose connections. Enterprise above adds white-label & redistribution rights and custom endpoints.

Evaluate first, commit later

Test everything on a free ULTRA key — no commitment. If it fits, we scope volume or white-label pricing.

Keep reading

More from the blog.

All Developer Tools
How to Swap Crypto Without KYC: ChangeNOW, DEXs, and What Actually Works

DeFi

How to Swap Crypto Without KYC: ChangeNOW, DEXs, and What Actually Works

A practical guide to swapping crypto without KYC in 2026. Covers ChangeNOW for cross-chain instant swaps, on-chain DEXs like Jupiter and Raydium, THORChain, and when each option makes sense.

9 minMay 23, 2026
Inside the Live Terminal Demo: REST Snapshots Plus WebSocket Updates for Solana and Robinhood Chain

API Guides

Inside the Live Terminal Demo: REST Snapshots Plus WebSocket Updates for Solana and Robinhood Chain

A tour of the MadeOnSol live terminal demo: which panels stream, which refresh and which load on request, how one REST snapshot and one WebSocket subscription feed each screen, and how to build the same thing in your own terminal.

9 minNovember 12, 2026
Build a Realtime Solana Token Intelligence Dashboard Without Polling

API Guides

Build a Realtime Solana Token Intelligence Dashboard Without Polling

Load a Solana token's risk, locks, flow and holder count with one include-scoped REST read, then keep the panel current from WebSocket events instead of polling. Runnable Node and browser code with watchTokenIntelligence() from madeonsol-x402 4.3.0.

9 minOctober 10, 2026
Building a Solana Portfolio Alert System: Price Drops, KOL Exits, and Recovery Signals (2026)

Developer Tools

Building a Solana Portfolio Alert System: Price Drops, KOL Exits, and Recovery Signals (2026)

Combine price dip webhooks, KOL coordination WebSocket streams, and wallet tracker events into a unified Solana alert system. TypeScript code for multi-signal trading decisions — sell when smart money exits, buy when they accumulate.

13 minMay 25, 2026
Robinhood Chain Trading Terminal Architecture: REST Snapshots Plus WebSocket Updates

API Guides

Robinhood Chain Trading Terminal Architecture: REST Snapshots Plus WebSocket Updates

How to structure a Robinhood Chain (chain id 4663) trading terminal: one include-scoped REST snapshot per token, then price, risk, lock and candle events over one WebSocket. Runnable code with watchTokenIntelligence() from robinhood-chain-x402 0.21.0, plus the Ultra firehose trade-off.

10 minOctober 10, 2026
How to Get pump.fun Token Trades via API: the Per-Mint Trade Tape (2026)

Guides

How to Get pump.fun Token Trades via API: the Per-Mint Trade Tape (2026)

One GET returns every buy and sell on a pump.fun token, newest first, with the executed price, the pool price at that slot, the wallet and the early-buyer rank. Cursor paging, buy/sell and wallet filters, and what the coverage block tells you before you trust the numbers.

9 minSeptember 5, 2026

Enjoyed this article?

Explore the live data.

Real-time KOL trades, Pump.fun deployer intel, and 1,200+ ranked Solana & Robinhood Chain tools — free to explore.

Open the KOL Tracker