Subscribe to live tweet, follower, and mention events via polling + Socket.IO. No API keys needed.
Overview
The streaming system provides near-real-time monitoring of Twitter/X activity by polling at configurable intervals and emitting events through Socket.IO. It uses:
Bull queue (Redis) for reliable scheduled polling
Browser pool for managed Puppeteer instances
Redis for deduplication and state persistence
Socket.IO for real-time event emission to clients
Quick Start
Node.js
import { createStream, stopStream, listStreams, setIO } from 'xactions/streaming';
// Optional: connect Socket.IO for real-time events
import { Server } from 'socket.io';
const io = new Server(httpServer);
setIO(io);
// Start a tweet stream
const stream = await createStream({
type: 'tweet',
username: 'elonmusk',
interval: 60, // Poll every 60 seconds (default)
authToken: 'your_auth_token'
});
console.log(stream);
// { id: 'abc123', type: 'tweet', username: 'elonmusk', status: 'active', interval: 60000 }
// List active streams
const streams = await listStreams();
// Stop a stream
await stopStream(stream.id);
MCP (AI Agents)
"Start monitoring @elonmusk's tweets in real-time"
→ Uses x_stream_start tool
"Show me all active streams"
→ Uses x_stream_list tool
"Stop monitoring @elonmusk"
→ Uses x_stream_stop tool
API
# Start a stream
curl -X POST http://localhost:3001/api/streams/start \
-H "Content-Type: application/json" \
-d '{"type": "tweet", "username": "elonmusk", "interval": 60}'
# List streams
curl http://localhost:3001/api/streams
# Stop a stream
curl -X POST http://localhost:3001/api/streams/stop \
-d '{"streamId": "abc123"}'