Skip to main content

WebSocket Delivery

Connect to the ScrapeBadger WebSocket endpoint to receive real-time tweet events from all your active stream monitors and filter rules.

Connection

Using wscat

Using Python

Using Node.js

Event format

Each WebSocket message is a JSON object:

Connection behavior

  • Authentication is done via the api_key query parameter
  • Heartbeat pings are sent every 30 seconds to keep the connection alive
  • Auto-reconnect is recommended in your client code — the server may close idle connections
  • All monitors and filter rules for the API key deliver to the same WebSocket connection
  • Multiple connections are supported per API key

Best practices

  1. Always implement reconnection logic with exponential backoff
  2. Process messages asynchronously to avoid blocking the WebSocket receive loop
  3. Use webhooks as a backup — WebSocket connections can drop, but webhooks retry delivery