Node.js Twitter WebSocket client

Build a Node.js client for TweetStream's Twitter/X WebSocket API with API-key subprotocol auth and production reconnect handling.

$199/mo for 50 accounts after a 3-day, 5-account trial

Published April 30, 2026 · 1 min read · TweetStream team

A Node.js TweetStream client opens a WebSocket with API-key subprotocol auth, parses JSON envelopes, and reconnects safely.

Connection details

Keep the API key in environment variables and connect from a server process.

  • wss://ws-global.tweetstream.io/ws
  • tweetstream.v1
  • tweetstream.auth.token.<API_KEY>

Reconnect strategy

Production clients should treat reconnects as normal. Keep event handling idempotent and make sure duplicate messages do not trigger duplicate trades or alerts.

Questions

How do I connect from Node.js?
Use the standard WebSocket client, pass tweetstream.v1 and tweetstream.auth.token.<API_KEY> as subprotocols, then parse JSON messages.
What makes it production ready?
Add exponential backoff, heartbeat handling, logging, and idempotent event processing around the WebSocket connection.

Run this workflow with TweetStream

TweetStream delivers posts, deletes, pins, profile and follow changes, and token and OCR enrichment as WebSocket events. Try it with the accounts from this guide.

$199/mo for 50 accounts after a 3-day, 5-account trial