Why a real-time crypto liquidation feed does not need a WebSocket
A real time crypto liquidation feed api usually means collecting exchange WebSockets: Bybit's allLiquidation topic, OKX's liquidation-orders channel, something custom for Hyperliquid because its public API has no liquidation feed at all. Each socket has its own subscription message, its own ping rules, its own reconnect behaviour and no shared notion of "what did I miss while I was down".
Server-Sent Events solve the parts that actually hurt. SSE is a plain HTTP GET whose response body stays open and delivers one small text frame per event. Every HTTP client can read it, every proxy and CDN passes it, and the protocol has replay built in: each frame carries an id: line, and a reconnecting client sends the last id it saw as the Last-Event-ID header. A browser's EventSource does that automatically. A Python script does it in two lines.
GET /api/v1/stream is that feed, merged across venues and normalised into one event shape. Liquidations are one of six event types on it; this post is about those, with the other five named so you can filter them in or out.
What /api/v1/stream sends
The response is text/event-stream. The first frame is retry: 3000, a hint to reconnect after three seconds if the connection drops. After that, each message is an id: line followed by a data: line holding one JSON event, and a : ping comment arrives every 15 seconds so idle proxies keep the connection open. On the wire:
retry: 3000
id: 184223091
data: {"id":184223091,"ts":1792974001532,"recv_ts":1792974001710,"type":"liquidation","venue":"hyperliquid","symbol":"ETH","side":"long","usd":48210.5,"px":3841.7,"sz":12.55}
: ping
id: 184223092
data: {"id":184223092,"ts":1792974004018,"recv_ts":1792974004122,"type":"liquidation","venue":"bybit","symbol":"SOL","side":"short","usd":9120.0}
Values above are illustrative; the field names are the served ones. Every event has id, ts (event time, ms), recv_ts (when we saw it, ms), type, venue and symbol (the base coin). The per-type fields:
liquidation:sideis the liquidated position's side (longorshort) andusdthe notional. Venues are OKX, Bybit and Hyperliquid, from $250 up. Hyperliquid events also carrypxandsz, because they come from exact fills.whale_transfer: $1M+ exchange deposits and withdrawals;exchange,chain,direction(infloworoutflow),amountin token units,usd.whale_position: Hyperliquid top-trader position changes of $25K+;action(entry, exit, increase, decrease),side,size,usdat entry price,address,change_pct.funding: every Hyperliquid perp;rate_1h,prev_rate_1h,settletrue on the first print of a new hour.oi_delta: every Hyperliquid perp; signedusd,pct,oi_usd, andwindow_sof about 60 for a minute move of at least max($25K, 0.03%) or about 300 for a 5-minute jump of at least max($5M, 1%).price_move: a 0.10%+ mark move over about a minute on perps trading $1M+ a day;pct,price,prev_price,window_s.
Filters are query parameters: types (comma list; an unknown type is a 400 unknown_event_type), symbols (comma list of base coins) and min_usd, which funding and price moves always pass. The stream is Pro (Pro Plus included); a Free key gets a 403 that points at the two JSON reads below. Each key can hold up to 3 open streams, and a fourth is a 429 too_many_streams.
curl -N "https://cryptodataapi.com/api/v1/stream?types=liquidation&symbols=BTC,ETH,SOL&min_usd=25000" \
-H "X-API-Key: cdk_live_your_key"
How do I resume a liquidation stream without missing events?
Send the last id you processed. Two ways do the same thing:
- The
Last-Event-IDrequest header, whichEventSourcesets for you on reconnect. - The
?since_id=query parameter, for clients that would rather not manage headers. If both are sent, the header wins.
Either replays the buffered events after that id before going live. The buffer holds about 2 hours, and ids only increase, including across our deploys, so an id you stored yesterday is still a valid cursor today even if it has aged out of the buffer; you simply resume from the oldest event still held.
To start cold with no gap and no duplicates, backfill from GET /api/v1/stream/recent first. It returns the newest events as JSON, oldest first, as {count, last_id, events} with the same event shape and filters plus limit (1 to 500, default 100), and any key can call it, Free included. Then open /stream?since_id=<last_id>. Everything between the backfill and the live connection is replayed from the buffer.
One more frame to handle: a client that reads too slowly is sent event: lagged with a JSON data line explaining it, and is disconnected. The fix is the same as any drop: reconnect with Last-Event-ID, and if it keeps happening, filter harder or read faster.
A Python SSE consumer with httpx
No SSE library is needed. The framing is line-based: frames are separated by a blank line, id: and data: are prefixes, and lines starting with : are comments to ignore. This consumer backfills from /stream/recent, goes live, and resumes on any error.
import json, time, httpx
API = "https://cryptodataapi.com/api/v1"
H = {"X-API-Key": "cdk_live_your_key"}
PARAMS = {"types": "liquidation", "symbols": "BTC,ETH,SOL", "min_usd": 25000}
def handle(ev):
print(ev["venue"], ev["symbol"], ev["side"], "liquidated", round(ev["usd"]))
# 1. Backfill, and learn the cursor.
r = httpx.get(f"{API}/stream/recent", headers=H, params={**PARAMS, "limit": 200}, timeout=30).json()
for ev in r["events"]:
handle(ev)
last_id = r["last_id"]
# 2. Go live; resume with Last-Event-ID after any drop.
while True:
headers = {**H, "Accept": "text/event-stream"}
if last_id is not None:
headers["Last-Event-ID"] = str(last_id)
try:
with httpx.stream("GET", f"{API}/stream", headers=headers, params=PARAMS,
timeout=httpx.Timeout(10.0, read=60.0)) as resp:
if resp.status_code == 403:
raise SystemExit("stream is Pro; use /stream/recent or /stream/delayed")
resp.raise_for_status()
event_name, data = "message", None
for line in resp.iter_lines():
if line == "": # end of frame
if data is not None:
if event_name == "lagged":
break # reconnect below with Last-Event-ID
ev = json.loads(data)
last_id = ev["id"]
handle(ev)
event_name, data = "message", None
elif line.startswith(":"):
continue # ": ping" every 15s
elif line.startswith("event:"):
event_name = line[6:].strip()
elif line.startswith("data:"):
data = line[5:].strip()
# "id:" and "retry:" lines need no handling: id is inside data too
except (httpx.HTTPError, httpx.ReadTimeout):
pass
time.sleep(3) # the server's retry hint
Two notes. The read timeout is set well above the 15-second ping interval, so a healthy but quiet stream is never mistaken for a dead one. And last_id is taken from inside the JSON rather than the id: line, which keeps the parser to three prefixes; the two values are always equal.
The keyless preview: /stream/delayed
If you want to see the shape of the feed before you sign up, GET /api/v1/stream/delayed needs no API key. It returns the events from a 3-minute window that ended 30 minutes ago, at most 900 of them, as {server_now, delay_ms, window_start, window_end, events_per_min, count, events}. It is cached for 60 seconds, and it is what drives the live tape on the homepage.
curl "https://cryptodataapi.com/api/v1/stream/delayed"
To replay the window at its original pace, show each event at ts + delay_ms. The event objects are identical to the live ones, so a client developed against the delayed read moves to the live stream by changing the URL and adding a key.
Stream, recent and delayed compared
/stream | /stream/recent | /stream/delayed | |
|---|---|---|---|
| Transport | SSE, stays open | JSON, one response | JSON, one response |
| Latency | Live | Live at call time, polled | 30 minutes behind |
| Depth | ~2h replay via Last-Event-ID | Newest 1 to 500 | A 3-minute window, up to 900 |
| Filters | types, symbols, min_usd, since_id | Same plus limit | None |
| Key | Pro or Pro Plus | Any key, Free included | No key |
| Concurrency | 3 per key | Normal rate limits | Cached 60s |
A Free key polling /stream/recent every few seconds gets the same events as the stream, just later and at the cost of its daily request budget: 100 requests a day before email verification, 1,000 after. The stream exists so a bot does not have to spend that budget asking "anything new?"
Which venues, and what is missing
The liquidation type merges three venues, and the honest reading of each:
- Hyperliquid is exact. Events come from per-fill node data, which is why they carry
pxandsz, and the same fills feed the queryable tape at/backtesting/hl-liquidations. - OKX and Bybit come from each venue's own public liquidation feed, as published.
- Binance is absent. It geo-blocks its liquidation stream from our infrastructure. Absolute notionals across the feed therefore run below a true all-exchange figure, which is why our own cascade detector at
/market-intelligence/squeeze-alertsis built on ratios against each coin's own baseline rather than on dollars. Read the short-squeeze detection post for that design.
The floor is $250 per event (lowered from $10K on 2026-09-28), so the stream is not a "big liquidations only" feed; use min_usd to make it one.
How to use this in a bot (and when not to)
Use the stream for reaction, not for history. Hold one connection per process, filtered to the coins you trade, and persist last_id on every event so a restart resumes instead of replaying two hours. Keep handlers fast; a slow consumer earns a lagged disconnect.
Combine it with a level. A single $50K liquidation means something different on a coin that liquidates $5M an hour than on one that liquidates $50K a day. liq_1h_vs_7d_median on /market-intelligence/liquidations is that baseline, per coin.
For anything older than two hours, do not use the stream. The buffer is a resume mechanism, not an archive. Bucketed liquidation history is /backtesting/hl-liquidation-bars and the per-fill tape is /backtesting/hl-liquidations, both Pro, both with keyset paging and a coverage block.
Do not open more than three streams per key, and do not fan one key across a fleet of workers each holding its own connection. Read once, publish internally.
The stream is included in Pro at $29 a month, and the 24-hour Pro trial on email verification reaches it. The event reference is at /docs under Stream; the keyless preview at /api/v1/stream/delayed needs nothing at all.
Frequently asked questions
Is there a real-time crypto liquidation feed that does not require a WebSocket?
Yes. GET /api/v1/stream is a Server-Sent Events feed over plain HTTP that merges OKX, Bybit and Hyperliquid liquidations from $250 up, with id lines for replay and a ping comment every 15 seconds.
How do I resume the liquidation stream after a disconnect?
Send the last id you processed as the Last-Event-ID header or as ?since_id=. Missed events are replayed from a buffer of about 2 hours, and ids only increase, including across deploys.
Can I try the liquidation stream without an API key?
GET /api/v1/stream/delayed needs no key and returns a 3-minute window of events that ended 30 minutes ago, at most 900, in the same event shape. /stream/recent returns the newest events as JSON with any key, Free included.
Which exchanges does the liquidation stream cover?
OKX, Bybit and Hyperliquid. Hyperliquid events are exact fills and carry px and sz. Binance is excluded because it geo-blocks its liquidation stream from our infrastructure.



