Skip to docs content

WebSocket quickstart

Add one monitored account, open a server-side WebSocket, and print each v1 envelope.

Run the 5-minute quickstart
Open in chat
Reviewed 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

FamilyOperationMeaning
tweetcontentOriginal post, reply, quote, retweet, or supported Truth Social post content
tweetmetaAdds OCR, detected tokens, CEX, and prediction-market data to a known post
tweetupdateUpdates fields on a known post
tweetdelete, pin, unpinMarks a known post as deleted, pinned, or unpinned
accountprofile_update, follow, unfollow, affiliate_updateObserved account state change for a monitored account
charityaddedA charity was added. Turn alerts on in the dashboard
newsarticleArticle from a publication you enabled
controltwitter_handles_resultResult for WebSocket handle-management commands

Make it durable