File size: 3,477 Bytes
d5434b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | # ClawSportBot WebSocket API Reference
## Connection
```
wss://stream.clawsportbot.io/v2/live
```
## Authentication
Send authentication immediately after connecting:
```json
{
"action": "auth",
"api_key": "YOUR_API_KEY"
}
```
**Response**:
```json
{
"type": "auth_success",
"tier": "pro",
"max_subscriptions": 5
}
```
## Subscribing to Channels
### Subscribe
```json
{
"action": "subscribe",
"channels": ["signals", "consensus", "market_sync"],
"match_ids": ["epl-2025-arsenal-chelsea"]
}
```
### Available Channels
| Channel | Description | Events |
|---------|-------------|--------|
| `signals` | Real-time agent signal generation | `signal_update` |
| `consensus` | Consensus formation and updates | `consensus_update`, `consensus_reached`, `consensus_failed` |
| `market_sync` | Market synchronization results | `market_sync_update` |
| `authorization` | Signal authorization decisions | `signal_authorized`, `signal_rejected` |
| `audit` | Post-match audit results | `audit_complete` |
| `network` | Network-wide events | `agent_online`, `agent_offline`, `network_stats` |
### Unsubscribe
```json
{
"action": "unsubscribe",
"channels": ["signals"],
"match_ids": ["epl-2025-arsenal-chelsea"]
}
```
## Event Messages
All events follow this structure:
```json
{
"type": "event_type",
"lifecycle_stage": "stage_name",
"data": { },
"timestamp": "2025-03-14T18:15:00Z"
}
```
### Signal Update
Emitted when an agent generates a new signal.
```json
{
"type": "signal_update",
"lifecycle_stage": "signal_generation",
"data": {
"signal_id": "sig_live001",
"agent_id": "match-analyst-v3",
"match_id": "epl-2025-arsenal-chelsea",
"signal_type": "match_outcome",
"prediction": {
"home_win": 0.52,
"draw": 0.24,
"away_win": 0.24
},
"confidence": 0.78,
"layer": "cognitive"
},
"timestamp": "2025-03-14T18:15:00Z"
}
```
### Consensus Reached
Emitted when multi-agent consensus is achieved.
```json
{
"type": "consensus_reached",
"lifecycle_stage": "cross_agent_validation",
"data": {
"consensus_id": "con_live001",
"match_id": "epl-2025-arsenal-chelsea",
"consensus_score": 0.80,
"threshold_met": true,
"weighted_prediction": {
"home_win": 0.50,
"draw": 0.26,
"away_win": 0.24
}
},
"timestamp": "2025-03-14T18:20:00Z"
}
```
### Signal Authorized
Emitted when a signal passes all authorization checks.
```json
{
"type": "signal_authorized",
"lifecycle_stage": "execution_authorization",
"data": {
"auth_id": "auth_live001",
"match_id": "epl-2025-arsenal-chelsea",
"authorized": true,
"delivery_channels": ["web_app", "telegram", "api"]
},
"timestamp": "2025-03-14T18:25:00Z"
}
```
## Connection Limits
| Tier | Max Connections | Max Subscriptions |
|------|----------------|-------------------|
| Free | 1 | 1 match |
| Pro | 5 | 10 matches |
| Institutional | Unlimited | Unlimited |
## Heartbeat
The server sends a heartbeat every 30 seconds:
```json
{
"type": "heartbeat",
"timestamp": "2025-03-14T18:30:00Z"
}
```
Clients should respond with:
```json
{
"action": "pong"
}
```
If no pong is received within 60 seconds, the connection is closed.
## Reconnection
If disconnected:
1. Wait 1 second before reconnecting
2. Double the wait time on each subsequent failure (exponential backoff)
3. Maximum wait time: 30 seconds
4. Re-authenticate and re-subscribe after reconnecting
|