How to stream pump.fun trades in real time
Working JavaScript and Python code that streams pump.fun launches and trades over WebSocket, free and without a key, then the whole market on one socket.
There are three ways to get pump.fun trades as they happen: read the chain yourself, poll someone's REST API every few seconds, or subscribe to a stream that does the reading for you. This guide takes the third route, with code that runs in a few minutes, and then goes through what breaks once you take it further.
Steps 1 and 2 are free and need no account and no key. Every snippet here was run against our live stream on 20 November 2026, and the output blocks are what it printed.
What you need
- Node.js 18 or newer, or Python 3.9 or newer.
- For steps 1 and 2, a Socket.IO client:
npm install socket.io-client, orpip install "python-socketio[client]". - For step 3, a plain WebSocket client:
npm install ws, orpip install websockets.
Step 1: every new pump.fun coin
The stream is at https://sol.shrine.trade. Ask for subscribe_new_tokens with the launchpads you want, and each new coin arrives as a new_token event.
- JavaScript
- Python
import { io } from "socket.io-client";
const QUOTES = {
So11111111111111111111111111111111111111112: "SOL",
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: "USDC",
};
const socket = io("https://sol.shrine.trade"); // no key, no account
// Subscribe inside "connect": Socket.IO reconnects by itself, and a fresh
// connection starts with no subscriptions.
socket.on("connect", () => {
socket.emit("subscribe_new_tokens", { protocols: ["PUMPFUN"] }, (ack) => {
if (ack?.error) console.error("subscribe failed:", ack.error, ack.message);
});
});
socket.on("new_token", (t) => {
const time = new Date(t.timestamp * 1000).toISOString().slice(11, 19);
const quote = QUOTES[t.quote] ?? t.quote.slice(0, 4) + "…";
console.log(`${time} ${(t.symbol ?? "").padEnd(10)} ${quote.padEnd(5)} ${t.mint} ${t.name ?? ""}`);
});
from datetime import datetime, timezone
import socketio
QUOTES = {
"So11111111111111111111111111111111111111112": "SOL",
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": "USDC",
}
sio = socketio.Client() # reconnects by itself
@sio.event
def connect():
# A fresh connection has no subscriptions, so (re)subscribe here.
sio.emit("subscribe_new_tokens", {"protocols": ["PUMPFUN"]})
@sio.on("new_token")
def on_new_token(t):
time = datetime.fromtimestamp(t["timestamp"], timezone.utc).strftime("%H:%M:%S")
quote = QUOTES.get(t["quote"], t["quote"][:4] + "…")
print(f"{time} {t.get('symbol', ''):<10} {quote:<5} {t['mint']} {t.get('name', '')}")
sio.connect("https://sol.shrine.trade") # no key, no account
sio.wait()
Run it with node new-coins.mjs or python new_coins.py. A few lines of what it printed for us:
00:40:31 USELESS pump… 6Cw28Z9ytoJxZaRmMUGbPQfnKN1h4bdyaAzwC7p7veNa USELESS COIN
00:40:35 KILOGRAM SOL ETXfiPm325fW1SWugMRooDsctVWBP6CTU1FazN1Upump KILOGRAM
00:40:39 EINSTEIN TTWo… 2bxs8bTp4XGGbBkovGhhFgy7haZ2sSyPSM2MAV7Zpump Einstein
00:40:42 USFUL USDC 422qhqqr7B9A3jtUrvK5VRGs7iUtXc5AwCRxZ5f52kDs USFUL COIN
00:40:51 DOG TTWo… FZA8DsnpZkbPJLAptsLYb8s85agmK7b6EK1ufhQCpump dog on gta
00:40:52 Dough 7q3j… 9QY6C6GgRGBWL2LrEUbB3rFjFGsEBHthkTU1Vbedpump Dough
Two things in there are worth knowing early. Not every mint ends in pump. And the third column is the coin's quote asset, which isn't always SOL: some coins are paired with USDC, some with pump.fun's PUMP token and some with other pump.fun coins (the TTWo… and 7q3j… lines). In the half hour after midnight UTC on 20 November we counted 385 launches, about 13 a minute, and 163 of them weren't paired with SOL.
The subscription goes inside the connect handler on purpose. Socket.IO reconnects by itself after a network blip, but the new connection starts with no subscriptions. Subscribe once at startup and your script goes quiet after its first reconnect, without an error.
Step 2: every trade on one coin
subscribe_trades takes a mint and sends a trade event for every buy and sell on that coin, on the bonding curve or, once it has graduated, on its PumpSwap pool.
- JavaScript
- Python
import { io } from "socket.io-client";
const mint = process.argv[2]; // node trades.mjs <mint>
const socket = io("https://sol.shrine.trade");
socket.on("connect", () => {
socket.emit("subscribe_trades", { mint }, (ack) => {
if (ack?.error) console.error("subscribe failed:", ack.error, ack.message);
else console.log("following pool", ack.pool);
});
});
socket.on("trade", (t) => {
const side = t.is_buy ? "BUY " : "SELL";
const price = t.quote_amount / t.token_amount; // in the coin's quote asset
console.log(
`${side} ${t.quote_amount.toFixed(4).padStart(10)} ` +
`${t.token_amount.toFixed(0).padStart(11)} tokens ` +
`price ${price.toExponential(3)} ${t.wallet.slice(0, 6)}… ${t.signature.slice(0, 8)}…`
);
});
import sys
import socketio
mint = sys.argv[1] # python trades.py <mint>
sio = socketio.Client()
def on_ack(ack):
if ack.get("error"):
print("subscribe failed:", ack["error"], ack.get("message"))
else:
print("following pool", ack["pool"])
@sio.event
def connect():
sio.emit("subscribe_trades", {"mint": mint}, callback=on_ack)
@sio.on("trade")
def on_trade(t):
side = "BUY " if t["is_buy"] else "SELL"
price = t["quote_amount"] / t["token_amount"] # in the coin's quote asset
print(
f"{side} {t['quote_amount']:>10.4f} {t['token_amount']:>11.0f} tokens "
f"price {price:.3e} {t['wallet'][:6]}… {t['signature'][:8]}…"
)
sio.connect("https://sol.shrine.trade")
sio.wait()
Pass the mint on the command line, for example one from step 1: node trades.mjs <mint>. On a coin a few minutes old it printed:
following pool 6atovw8m2DquLFmuYqJ3dLr1K2Accy6kswmZYQCPQP4F
SELL 1.6631 55993278 tokens price 2.970e-8 tBVFi3… ZB7rqfHE…
BUY 1.9753 65858222 tokens price 2.999e-8 DdiftP… BnLp7GED…
SELL 0.0137 429831 tokens price 3.195e-8 GQpMwq… 43uB1qX5…
BUY 0.2024 6298574 tokens price 3.214e-8 6GV9Au… 3uGTDMXB…
What each trade carries:
| Field | |
|---|---|
mint, pool, protocol | the coin, the pool it traded in, and PUMPFUN (curve) or PUMPSWAP |
is_buy | true when the trader received the coin |
token_amount, quote_amount | in whole units, decimals already applied |
wallet | the trader |
signature | the transaction |
timestamp | the block's time, in whole seconds |
There's no price field: divide quote_amount by token_amount, as the script does. That price is in the coin's quote asset, which you got in step 1, so don't label it SOL without checking.
One connection can follow up to 50 coins, and without a key you can have two connections open per stream type. That's plenty for a watchlist, and not enough for the whole market.
Step 3: the whole market on one socket
To see every trade on pump.fun, or on every launchpad, use the Advanced Data Stream. It's a plain WebSocket with one event per transaction: launches, trades, curve completions, migrations and liquidity, each with the pool's reserves and what the transaction paid to land. You can filter it with protocols and actions in the URL. It needs a key from the Lite plan or above.
This script uses it to answer a question the per-coin stream can't: what happens to every new pump.fun coin in its first minute? For each SOL-paired launch it counts buys, sells, SOL traded and distinct wallets for 60 seconds, then prints a line with how far up the bonding curve the coin got.
- JavaScript
- Python
import WebSocket from "ws";
const KEY = process.env.SHRINE_API_KEY; // a Lite, Developer or Professional key
if (!KEY) throw new Error("Set SHRINE_API_KEY to your key first");
const BASE = "wss://sol.shrine.trade/api/stream/ws?protocols=PUMPFUN&actions=create,buy,sell";
const WSOL = "So11111111111111111111111111111111111111112";
const WINDOW_MS = 60_000;
const coins = new Map(); // mint -> its first minute so far
let lastSlot = 0;
// The same transaction can arrive twice, so remember what we have counted.
// A launch sends a trade and a create with one signature, hence the action.
// Two sets, so memory stays flat.
let seen = new Set(), seenOld = new Set();
function firstTime(id) {
if (seen.has(id) || seenOld.has(id)) return false;
seen.add(id);
if (seen.size > 100_000) [seenOld, seen] = [seen, new Set()];
return true;
}
function onEvent(e) {
if (!firstTime(`${e.signature}:${e.pool}:${e.action}`)) return;
lastSlot = Math.max(lastSlot, e.block);
if (e.action === "create") {
if (e.quoteMint !== WSOL) return; // SOL-paired coins only
coins.set(e.mint, { symbol: e.symbol, buys: 0, sells: 0, sol: 0, wallets: new Set(), progress: 0, graduated: false });
setTimeout(() => report(e.mint), WINDOW_MS);
return;
}
const c = coins.get(e.mint);
if (!c) return; // launched before we connected, or not SOL-paired
e.action === "buy" ? c.buys++ : c.sells++;
c.sol += e.quoteAmount;
for (const w of e.tradersInvolved) c.wallets.add(w);
if (e.completesCurve) c.graduated = true;
else c.progress = (1_073_000_000 - e.tokensInPool) / 793_100_000;
}
function report(mint) {
const c = coins.get(mint);
coins.delete(mint);
const state = c.graduated ? "graduated" : `${(c.progress * 100).toFixed(0)}% sold`;
console.log(
`${(c.symbol ?? "").padEnd(10)} ${String(c.buys).padStart(4)} buys ${String(c.sells).padStart(4)} sells ` +
`${c.sol.toFixed(2).padStart(7)} SOL ${String(c.wallets.size).padStart(4)} wallets ${state}`
);
}
function connect() {
// After a drop, ask for everything since the last slot we saw.
const url = BASE + (lastSlot ? `&sinceSlot=${lastSlot}` : "");
const ws = new WebSocket(url, { headers: { "x-api-key": KEY } });
ws.on("unexpected-response", (req, res) => {
res.setEncoding("utf8");
res.on("data", (body) => { console.error(res.statusCode, body); process.exit(1); });
});
ws.on("message", (raw) => {
const e = JSON.parse(raw);
if (e.type) return; // connected, resumed, pong, lagged: about the socket
onEvent(e);
});
ws.on("close", () => setTimeout(connect, 1000));
ws.on("error", (err) => console.error("stream:", err.message)); // "close" follows
}
connect();
import asyncio
import json
import os
import sys
import websockets # version 14 or newer
KEY = os.environ.get("SHRINE_API_KEY") or sys.exit("Set SHRINE_API_KEY to your key first") # Lite or up
BASE = "wss://sol.shrine.trade/api/stream/ws?protocols=PUMPFUN&actions=create,buy,sell"
WSOL = "So11111111111111111111111111111111111111112"
WINDOW = 60 # seconds
coins = {} # mint -> its first minute so far
last_slot = 0
# The same transaction can arrive twice, so remember what we have counted.
# A launch sends a trade and a create with one signature, hence the action.
seen, seen_old = set(), set()
def first_time(key):
global seen, seen_old
if key in seen or key in seen_old:
return False
seen.add(key)
if len(seen) > 100_000:
seen_old, seen = seen, set()
return True
def report(mint):
c = coins.pop(mint)
state = "graduated" if c["graduated"] else f"{c['progress']:.0%} sold"
print(f"{c['symbol']:<10} {c['buys']:>4} buys {c['sells']:>4} sells "
f"{c['sol']:>7.2f} SOL {len(c['wallets']):>4} wallets {state}", flush=True)
def on_event(e):
global last_slot
if not first_time((e["signature"], e["pool"], e["action"])):
return
last_slot = max(last_slot, e["block"])
if e["action"] == "create":
if e["quoteMint"] == WSOL: # SOL-paired coins only
coins[e["mint"]] = {"symbol": e.get("symbol") or "", "buys": 0, "sells": 0, "sol": 0.0,
"wallets": set(), "progress": 0.0, "graduated": False}
asyncio.get_running_loop().call_later(WINDOW, report, e["mint"])
return
c = coins.get(e["mint"])
if c is None:
return # launched before we connected, or not SOL-paired
c["buys" if e["action"] == "buy" else "sells"] += 1
c["sol"] += e["quoteAmount"]
c["wallets"].update(e["tradersInvolved"])
if e.get("completesCurve"):
c["graduated"] = True
else:
c["progress"] = (1_073_000_000 - e["tokensInPool"]) / 793_100_000
async def main():
while True:
# After a drop, ask for everything since the last slot we saw.
url = BASE + (f"&sinceSlot={last_slot}" if last_slot else "")
try:
async with websockets.connect(url, additional_headers={"x-api-key": KEY}, max_size=None) as ws:
async for raw in ws:
e = json.loads(raw)
if "type" not in e: # connected, resumed, pong, lagged: about the socket
on_event(e)
except websockets.InvalidStatus as err:
sys.exit(f"{err.response.status_code} {err.response.body.decode()}")
except (OSError, websockets.ConnectionClosed) as err:
print("stream:", err, file=sys.stderr)
await asyncio.sleep(1)
asyncio.run(main())
Run it with your key in the environment: SHRINE_API_KEY=sk_… node first-minute.mjs. Three parts of it are there because of how a live stream behaves, and they are the subject of the next section: the duplicate check, the sinceSlot on reconnect, and the SOL-only filter.
What will bite you
A reconnect loses your subscriptions
Covered above, but it's the one that costs people a night of missed trades. On Socket.IO, subscribe in the connect handler. On the plain WebSocket, the filter is in the URL, so a reconnect carries it.
The same transaction can arrive twice
The stream sends a block as soon as it's seen, before the network confirms it. Now and then a block is dropped and its transactions land again in a later one, and you get the same signature twice with a different block. Count by signature (plus pool and action, since a launch sends a trade and a create with one signature) and you're safe.
The same speed has a rarer cost: a block can first run on a state the network then drops, so an event's amounts can differ from the final chain's. If you're doing accounting rather than trading, check the transaction once its block is confirmed.
A reconnect shouldn't mean a gap
sinceSlot replays everything since that slot before going live again, up to 24 hours back, so a dropped connection doesn't cost you any events. That's why the script remembers the last block it saw. The replay overlaps what you already have, and the duplicate check takes care of that.
One transaction, several swaps
Bots and routers often trade more than once in a transaction, or for several wallets at once. The stream sends one event per pool per transaction with the net amounts, and lists the swaps in breakdown. The wallet that paid the fee (txSigner) isn't always the trader, since many bots send through relayers; use tradersInvolved.
Not every coin is priced in SOL
You saw it in step 1. If you add up quoteAmount across coins without checking quoteMint, you'll be adding USDC to SOL. The script tracks SOL-paired coins only for that reason.
On some PumpSwap pools SOL is the base
Most PumpSwap pools hold the coin as the base and SOL as the quote. Some hold them the other way round, a few busy ones among them, and they carry about a third of PumpSwap's swaps. On those pools the program's own buy instruction is a sale of the coin. If you decode PumpSwap yourself, check the pool's mints before you trust the instruction name. Our stream already reports these from the coin's side.
The buy that graduates a coin has two prices
Since pump.fun's October 2026 upgrade, a buy can be bigger than what's left on the curve. It empties the curve at the curve's price and buys the rest from the new PumpSwap pool at its opening price, in one transaction. The event carries "completesCurve": true and two breakdown entries, tagged "stage": "curve" and "stage": "postComplete". The bonding curve guide explains why the two prices are nearly the same.
Timestamps are seconds
timestamp is the block's time in whole seconds, so dozens of trades share one. To order trades, sort by block, then txIndex, then each swap's ixIndex and innerIndex.
Doing it yourself instead
Nothing here needs our stream. If you'd rather read the chain directly, these are your options and what each one takes.
logsSubscribe on an RPC
Every Solana RPC offers it, public ones for free. You subscribe to logs that mention the pump.fun program and decode the Anchor events in the Program data: lines. It works for a demo. In production, public endpoints can drop notifications under load, failed transactions arrive too (check the err field), and Solana cuts a transaction's logs at 10 KB, so on a busy router transaction the event you wanted can be cut off.
A Yellowstone gRPC feed
Most paid RPC providers sell one. You get whole transactions with balances and inner instructions, quickly and reliably. Then you're decoding every instruction yourself: pump.fun alone has several buy and sell instructions across its versions, PumpSwap pools come in both orientations, routers wrap all of them, and every program upgrade adds accounts or changes a layout.
Shreds
The fastest data on Solana is the shreds a leader sends before the block is executed. There are no execution results in them, so you work out balances and reserves yourself. We do this for our Ultra Fast Shred Stream, on the Developer and Professional plans.
Any of the three makes a good weekend project. The long-term work is keeping it correct through pump.fun's upgrades, and that's the part a hosted stream takes off your hands.
When something you send fails, pump.fun and PumpSwap error codes explains the hex.