How to stream with RabbitStream
Rabbitstream Quickstart: Connecting with TypeScript and Rust
RabbitStream is designed to be a seamless, drop-in replacement for your existing Yellowstone gRPC clients, requiring only a change of endpoint URL.
Access and Authentication
RabbitStream requires a valid Shyft gRPC access token. gRPC access is included with our Build, Grow, and Accelerate plans. Once you have your token, you can access the stream using the following regional endpoints:
Ams (Amsterdam)
https://rabbitstream.ams.shyft.to/
VA (Virginia, Ashburn)
https://rabbitstream.va.shyft.to/
NY (New York)
https://rabbitstream.ny.shyft.to/
Fra (Frankfurt)
https://rabbitstream.fra.shyft.to/
Connecting to RabbitStream: Client Examples
Once you have your Shyft gRPC Access Token, you can connect to Rabbitstream in the following manner:
import "dotenv/config";
import Client, {
CommitmentLevel,
SubscribeRequest,
SubscribeRequestAccountsDataSlice,
} from "@triton-one/yellowstone-grpc";
const client = new Client(
"https://rabbitstream.ams.shyft.to/",
process.env.X_TOKEN,
undefined
);
const req: SubscribeRequest = {
accounts: {},
slots: {},
transactions: {
pumpFun: {
vote: false,
failed: false,
signature: undefined,
accountInclude: ["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"],
accountExclude: [],
accountRequired: [],
},
},
transactionsStatus: {},
entry: {},
blocks: {},
blocksMeta: {},
accountsDataSlice: [] as SubscribeRequestAccountsDataSlice[],
ping: undefined,
commitment: CommitmentLevel.PROCESSED,
};
async function handleStream(client: Client, args: SubscribeRequest) {
// Subscribe for events
console.log(`Subscribing and starting stream...`);
const stream = await client.subscribe();
// Create `error` / `end` handler
const streamClosed = new Promise<void>((resolve, reject) => {
stream.on("error", (error) => {
console.log("ERROR", error);
reject(error);
stream.end();
});
stream.on("end", () => {
resolve();
});
stream.on("close", () => {
resolve();
});
});
// Handle updates
stream.on("data", (data) => {
console.log("Received data....");
console.dir(data, { depth: null });
});
// Send subscribe request
await new Promise<void>((resolve, reject) => {
stream.write(args, (err: any) => {
if (err === null || err === undefined) {
resolve();
} else {
reject(err);
}
});
}).catch((reason) => {
console.error(reason);
throw reason;
});
await streamClosed;
}
async function subscribeCommand(client: Client, args: SubscribeRequest) {
while (true) {
try {
await handleStream(client, args);
} catch (error) {
console.error("Stream error, restarting in 1 second...", error);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
}
subscribeCommand(client, req);
Performance Benchmarks: The Speed Advantage
RabbitStream is ideal for applications that need low-latency transaction monitoring, such as DeFi dashboards, arbitrage bots, or token analytics tools. We compare the detection latency between RabbitStream and Yellowstone gRPC. All the code for this comparison tool is available on GitHub for you to try out.

Last updated
Was this helpful?