WebSocket Connections
WebSocket connections provide real-time, bidirectional communication with Scrapest for receiving Twitter/X data instantly.Connection Setup
Endpoint
Authentication
Include your API key in the connection headers:Connection Example
Message Format
Subscription Request
Data Response
Managing Connections
Unsubscribe
Close Connection
Error Handling
Common WebSocket error codes:1000: Normal closure1001: Going away1006: Abnormal closure1008: Policy violation
Best Practices
- Reconnection Logic: Implement automatic reconnection with exponential backoff
- Rate Limiting: Respect connection limits and message rates
- Error Handling: Handle all WebSocket events properly
- Filter Optimization: Use specific filters to reduce data volume
Rate Limits
- Maximum 5 concurrent WebSocket connections per API key
- 100 messages per second rate limit
- Automatic disconnection on sustained violations