Streaming
Trades as they land, filtered before they reach you.
wss://wss.hexio.trade/v1/stream/transactionsLive trades. Available from Pro upward, or as an add-on.
Connection parameters
| Name | Type | Description |
|---|---|---|
api_key | string | Required. Browsers cannot set headers on a WebSocket handshake — see Authentication. |
wallets | csv | Only trades from these addresses. |
markets | csv | Only trades in these condition ids. |
min_usdc | float | Drop trades below this size. The single most effective filter — most trades are dust. |
What arrives
The first message confirms what you are subscribed to. Filters you did not set come back empty, which is how you check a typo did not silently widen the subscription.
{
"type": "subscribed",
"filters": { "wallets": [], "markets": [], "min_usdc": 0.0 },
"note": "credits billed per 100 delivered messages"
}min_usdc.A connection that survives the night
Networks drop, deploys happen, laptops sleep. Anything long-lived needs reconnect logic, and it needs to tell apart “try again” from “stop”.
function connect() {
const qs = new URLSearchParams({ api_key: KEY, min_usdc: '500' });
const ws = new WebSocket(`wss://wss.hexio.trade/v1/stream/transactions?${qs}`);
let attempt = 0;
ws.onopen = () => { attempt = 0; };
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.type === 'subscribed') { console.log('filters', msg.filters); return; }
handleTrade(msg);
};
ws.onclose = (e) => {
// 4401/4402/4429 are decisions, not blips. Reconnecting cannot fix a revoked
// key or an empty balance, and hammering a 4429 keeps the slot occupied.
if ([4401, 4402, 4429].includes(e.code)) {
console.error('stream refused:', e.code, e.reason);
return;
}
const wait = Math.min(2 ** attempt++ * 1000, 30000) + Math.random() * 500;
setTimeout(connect, wait);
};
return ws;
}Close codes
| Code | Meaning | Reconnect? |
|---|---|---|
| 4401 | Key missing, wrong, or revoked | No |
| 4402 | Out of credits | No |
| 4429 | Too many concurrent streams for the plan | Close another first |
| 1006 | Connection dropped | Yes, with backoff |
Concurrent stream allowance is per plan — 1 on Pro, 3 on Business. Check parallel_streams in /v1/usage.
Never from the browser directly
The key goes in the URL, so a browser connection publishes it to anyone who opens devtools — and to proxy logs and browser history on the way. Connect from your backend and relay to the client over your own socket. That also lets one upstream connection serve every user, which is what the per-plan stream limit assumes.
min_usdc and wallets means the messages are never sent — and never billed. Receiving everything and discarding most of it in an if costs the same as reading it all.