> For the complete documentation index, see [llms.txt](https://docs.hydromancer.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hydromancer.xyz/readme/websocket/alltwapstatusupdates.md).

# allTwapStatusUpdates

{% hint style="info" %}
💧New endpoint - this endpoint is not a part of original Hyperliquid API and is added by us for builder convenience.
{% endhint %}

### Subscribe

```
{ 
    "type": "subscribe",
    "subscription": {
        "type": "allTwapStatusUpdates"
    }
} 
```

### Unsubscribe

```
{ 
    "type": "unsubscribe",
    "subscription": {
        "type": "allTwapStatusUpdates"
    }
}
```

{% hint style="info" %}
**Reconnection Note:** When reconnecting with a session, replay and live events may overlap. Deduplicate using `(time, txIndex)` - skip updates where this tuple is at or before your last processed update. See [Session Management](/readme/websocket/session-management-and-reconnection.md#deduplication) for details.
{% endhint %}

<details>

<summary>allTwapStatusUpdates data format</summary>

```json
{
  "type": "allTwapStatusUpdates",
  "seq": 1,
  "cursor": "500:1704067200000:3",
  "updates": [
    {
      "time": "2025-09-03T10:48:14.285201806", // time of update
      "createdAt": 1756896494285, // time of creation
      "twapId": 12345,
      "user": "0x742d35cc6634c0532925a3b844bc9e7595f7f2e2",
      "coin": "ETH",
      "side": "B",

      "status": "activated", // can be activated, finished, terminated or error
      "statusMessage": null, // only non null when status is error

      "sz": "100.5",
      "minutes": 60,
      "reduceOnly": false,
      "randomize": true,

      "executedSz": "25.125",
      "executedNtl": "50250.0",
      "txIndex": 3
    },
    {
      "time": "2025-09-03T10:48:14.285201806",
      "createdAt":1756896494285,
      "twapId": 12346,
      "user": "0x123d35cc6634c0532925a3b844bc9e7595f7f2e2",
      "coin": "BTC",
      "side": "A",

      "status": "error",
      "statusMessage": "Insufficient spot balance",

      "sz": "0.5",
      "minutes": 30,
      "reduceOnly": true,
      "randomize": false,

      "executedSz": "0.1",
      "executedNtl": "4500.0",
      "txIndex": 5
    }
  ]
}

```

</details>

### Examples

{% tabs %}
{% tab title="Javascript" %}

```javascript
const WebSocket = require('ws');

const ws = new WebSocket(`wss://api.hydromancer.xyz/ws?token=${process.env.HYDROMANCER_API_KEY}`);

ws.on('message', (data) => {
    const msg = JSON.parse(data);

    if (msg.type === 'connected') {
        // Subscribe to TWAP status updates
        ws.send(JSON.stringify({
            type: 'subscribe',
            subscription: {
                type: 'allTwapStatusUpdates'
            }
        }));
    } else if (msg.type === 'ping') {
        ws.send(JSON.stringify({ type: 'pong' }));
    } else if (msg.type === 'allTwapStatusUpdates') {
        console.log(`Received ${msg}`);
    }
});
```

{% endtab %}

{% tab title="Python" %}

```python
import websocket
import json
import os

def on_message(ws, message):
    msg = json.loads(message)

    if msg['type'] == 'connected':
        ws.send(json.dumps({
            "type": "subscribe",
            "subscription": {
                "type": "allTwapStatusUpdates"
            }
        }))
    elif msg['type'] == 'ping':
        print("Received ping, sending pong")
        ws.send(json.dumps({'type': 'pong'}))
    elif msg['type'] == 'allTwapStatusUpdates':
        print(f"Received {msg}")
    elif msg['type'] == 'subscriptionUpdate':
        print(f"Subscription update: {msg}")
    elif msg['type'] == 'error':
        print(f"Error: {msg}")
    else:
        print(f"Unknown message type: {msg}")

ws = websocket.WebSocketApp(
    f"wss://api.hydromancer.xyz/ws?token={os.environ.get('HYDROMANCER_API_KEY')}",
    on_message=on_message
)
ws.run_forever()
```

{% endtab %}
{% endtabs %}
