WebSocket Quickstart Guide
Connect to TweetStream's real-time Twitter alert stream in minutes
Getting Started
Connect to TweetStream using WebSocket subprotocols for authentication. No HTTP headers or query strings needed - just include your API key in the protocol list when creating the connection.
Connection Details
| Endpoint | wss://ws.tweetstream.io/ws |
| Protocol 1 | tweetstream.v1 |
| Protocol 2 | tweetstream.auth.token.YOUR_API_KEY |
Quick Start Example
Copy and paste this code to get connected immediately:
Production Example
For production use, add reconnection handling:
Envelope Format
All messages use a consistent envelope structure:
v- Protocol version (always 1)t- Message type:tweetorcontrolop- Operation:content,meta,update,deletets- Unix timestamp in millisecondsd- Payload data (varies by type and operation)
Common Issues
- Authentication failed: Verify your API key is from an active subscription
- Connection limit reached: Close existing connections or upgrade your plan
- No tweets appearing: Check that accounts are tracked in your dashboard