Tweet Catcher
  • Introduction
  • Terms of Service
  • Privacy Policy
  • Tweet Catcher Guide
    • Account Automation Tool
      • Tweet Catcher Application
        • Home Section
          • Password / Invite window
        • Task Creation
          • Twitter Tasks
        • Profiles
        • Discord Monitoring
          • Link Extension
        • Twitter
          • Twitter Profiles
          • Twitter Proxies
          • Suspension Appeal Module
            • How to Get A Catchall
        • Raffle & WL
          • Discord Profiles
          • Discord Proxies
        • Settings
      • Tweet Catcher Extension
        • Installation / Update
        • Profiles
        • Discord
        • Settings
    • Tweet Catcher Monitor
      • Dashboard
      • Tasks Creation
      • Telegram
      • Discord Bot
      • Extra Tasks
      • Pro Plan
        • WebSocket
          • Events
        • API
          • Manage Tasks
          • User Data
Powered by GitBook
On this page
  • Authentication
  • Here's a representation of the connection to Tweet Catcher server
  • Data format of the events
  • Simple JavaScript implementation example
  1. Tweet Catcher Guide
  2. Tweet Catcher Monitor
  3. Pro Plan

WebSocket

PreviousPro PlanNextEvents

Last updated 2 days ago

Authentication

To connect to Tweet Catcher servers you must submit a valid user token, you can get your token on the , by creating a task and selecting "WebSocket" as option

Here's a representation of the connection to Tweet Catcher server

[Client] 
Establish connection to wss://monitor-api.tweet-catcher.com/websocket

[Tweet Catcher] Hello event
{ op: 10, heartbeat_interval: 45000 }

[Client] Heartbeat event
{ op: 1 }

[Tweet Catcher] Heartbeat ACK event
{ op: 11 }

[Client] Login
{ op: 2, token: "YOUR_TOKEN" }

[Tweet Catcher] Disconnection event(s)
{ op: 3, text: "REASON_OF_DISCONNECTION" }

[Tweet Catcher] Ready event
{ op: 4 }

[Tweet Catcher] Monitor event(s)
{
  op: 0,
  d: EventData
}

Data format of the events

Simple JavaScript implementation example

const WebSocket = require("ws")

const loginToken = "YOUR_TOKEN"

let heartbeatInt = null

const ws = new WebSocket("wss://monitor-api.tweet-catcher.com/websocket")

ws.on('error', console.error)

ws.on('close', async (code) => {
  console.warn("Websocket connection closed with code:", code)
  clearInterval(heartbeatInt)
  /* Your reconnection logic */
})

ws.on('message', (data) => {
  try
  {
    const objData = JSON.parse(data)
//    console.log(objData)
    switch (objData.op)
    {
      case 0: // New Notification
        console.log("New notification", objData.d)
        break

      case 3: // Connection status updates
        console.warn("Server connection closed with message:", objData.text)
        break
      
      case 4: // Ready event
        console.log("Logged in!")
        break

      case 10: // Init heartbeat
        ws.send(JSON.stringify({ op: 2, token: loginToken })) // Login
        heartbeatInt = setInterval(() => {
          try
          { ws.send('{"op":1}') }
          catch (e)
          { console.error("Failed to send hearthbeat", e) }
        }, objData.heartbeat_interval)
        break
    }
  }
  catch (e)
  {
    console.error("Error on ws on message:", e)
  }
})
Events
dashboard