Skip to main content
Connect to the WebSocket to receive events from every task whose destination is WebSocket, plus Twitter Global keyword events
Authenticate with your API key. It is in Settings → API, and also appears as Login Token on any task that delivers to WebSocket. Send the raw key without a Bearer prefix

Connection flow

1

Receive hello

As soon as the socket opens, the server sends:
2

Log in

Send your key:
This must be your first message. Sending any other opcode first closes the connection with user not logged in
3

Start the heartbeat

Every heartbeat_interval milliseconds, send { "op": 1 }. The server answers each one with { "op": 11 }.If a heartbeat is missed, the server sends { "op": 3, "text": "About to close the connection, no heartbeat" } and closes the socket
4

Receive ready

A successful login returns op 4. Its d object contains event: "LOGIN", expireAt, tasksLimit, globalMonitorTasksLimit, and tasks
5

Receive events

Each notification arrives as { "op": 0, "d": { ...event } }. See Events for every shape of d

Opcodes

Example

This Node.js client uses the ws package. It logs in, keeps the heartbeat going, and reconnects with a growing delay when the connection drops
client.js
Run it with your key in the environment:

Reconnecting

The server does not resume a dropped session, and events sent while you are disconnected are not replayed. On every new connection, log in again and restart the heartbeat
If op 3 reports a bad key, fix the key before reconnecting. Retrying with the same key fails again
Resetting your API key closes every open WebSocket connection. Update your clients with the new key