24-hour replay stream
You can replay 24 hours of the stream. Whatever drops between the chain and your bot, the events arrive late instead of never.
- Our feed reconnects from the last slot it saw and replays everything it missed from the chain, for gaps of up to 24 hours. Every stream on this API is built from that feed, so a stream never has a hole in it.
- Your socket resumes from a slot. Pass
sinceSloton reconnect and the last two minutes are sent to you first, markedreplayed, then live events follow. - Everything older is in the hourly replay files: every event of every hour, the same format as the stream, for backtests and for any gap longer than two minutes.
Resume from a slotโ
Every stream event carries block, the slot it was in. Keep the last one you handled. On reconnect, pass it as sinceSlot and everything published since that slot is sent to you first, through your usual filter, then the live events follow:
import { io } from "socket.io-client";
const socket = io("https://sol.shrine.trade");
let lastSlot = 0;
socket.on("connect", () => {
socket.emit("subscribe_stream", { protocols: ["PUMPFUN", "PUMPSWAP"], sinceSlot: lastSlot || undefined }, (ack) => {
// ack.replayed events were sent before this ack; ack.oldestSlot is how far back we could reach
if (lastSlot && ack.oldestSlot > lastSlot) console.warn("gap before slot", ack.oldestSlot);
});
});
socket.on("stream", (e) => {
lastSlot = Math.max(lastSlot, e.block);
if (e.replayed) { /* delivered late, not live */ }
// ...
});
Replayed events are the original events with "replayed": true added, in their original order. The acknowledgement carries replayed (how many were sent) and oldestSlot (the oldest slot still on the socket). If oldestSlot is newer than your sinceSlot, the stretch before it is in the hourly files.
The resume includes sinceSlot itself, so the last slot you handled is sent again. Deduplicate on signature plus pool if a double counts for you. No key, no charge.