WebSocket quickstart
Add one monitored account, open a server-side WebSocket, and print each v1 envelope.
Run the 5-minute quickstartReviewed against product code on September 2, 2026
Run a 5-minute smoke test
Add one monitored account, copy the example, and run it. TweetStream connected confirms authentication. Events appear when that account posts.
Run the TypeScript smoke test
typescript
// bun add ws
// TWEETSTREAM_API_KEY=ts_... bun run smoke.ts
import WebSocket from "ws";
const apiKey = process.env.TWEETSTREAM_API_KEY;
if (!apiKey) {
throw new Error("Missing TWEETSTREAM_API_KEY");
}
const ws = new WebSocket("wss://ws-global.tweetstream.io/ws", [
"tweetstream.v1",
`tweetstream.auth.token.${apiKey}`,
]);
ws.on("open", () => {
console.log("TweetStream connected");
});
ws.on("message", (raw) => {
const event = JSON.parse(raw.toString());
console.log(event.t, event.op, event.d);
});
ws.on("close", (code, reason) => {
console.log("TweetStream closed", code, reason.toString());
});
ws.on("unexpected-response", (_request, response) => {
console.error("Connection rejected", response.statusCode, response.statusMessage);
response.resume();
process.exitCode = 1;
});
ws.on("error", (error) => {
console.error("WebSocket error", error.message);
});Route operations
| Family | Operation | Meaning |
|---|---|---|
| tweet | content | Original post, reply, quote, retweet, or supported Truth Social post content |
| tweet | meta | Adds OCR, detected tokens, CEX, and prediction-market data to a known post |
| tweet | update | Updates fields on a known post |
| tweet | delete, pin, unpin | Marks a known post as deleted, pinned, or unpinned |
| account | profile_update, follow, unfollow, affiliate_update | Observed account state change for a monitored account |
| charity | added | A charity was added. Turn alerts on in the dashboard |
| news | article | Article from a publication you enabled |
| control | twitter_handles_result | Result for WebSocket handle-management commands |