The liquidation order snapshot stream provides liquidation order information for trading pairs in the market. Receive liquidation orders for futures across the whole market in real time over WebSocket: every time a forced liquidation happens on an exchange, you receive its exchange, trading pair, side, price and amount. Suitable for liquidation alerts, real-time dashboards and risk control signals.
The following API plans can call this endpoint: Standard Professional Enterprise
| Item | Details |
|---|---|
| Connection URL | wss://open-ws.coinglass.com/ws-api?cg-api-key=YOUR_API_KEY |
| Subscribe message | method is subscribe, channels is ["liquidation_orders"] |
| Heartbeat | We recommend sending ping every 20 seconds; receiving pong means the connection is working |
| Message fields | base_asset, exchange, symbol, price, side, volume_usd, time (milliseconds) |
| API plan | Standard and above |
| Querying missed data | The REST Liquidation Orders endpoint; last 7 days |
Real-Time Liquidation Order Push
Channel: liquidation_orders
liquidation_ordersTo subscribe to the liquidation_orders channel, send the following message:
{
"method": "subscribe",
"channels": ["liquidation_orders"]
}Response Example
When data is received, the response looks like this:
{
"channel": "liquidation_orders",
"data": [
{
"base_asset": "BTC",
"exchange": "Binance",
"price": 56738.00,
"side": 2, //side=1 Long liquidation side=2 Short liquidation
"symbol": "BTCUSDT",
"time": 1725416318379,
"volume_usd": 3858.18400
}
]
}| Field | Description |
|---|---|
base_asset | Coin |
exchange | Exchange |
symbol | Trading pair |
price | Liquidation price |
side | Side: 1 is a long liquidation, 2 is a short liquidation |
volume_usd | Liquidation amount (USD) |
time | Liquidation time, timestamp in milliseconds |
Connecting and Subscribing
- Connect: Append your API Key to the URL:
wss://open-ws.coinglass.com/ws-api?cg-api-key=YOUR_API_KEY - Subscribe to the channel: After connecting, send
{"method": "subscribe", "channels": ["liquidation_orders"]} - Keep the heartbeat going: We recommend sending
pingevery 20 seconds; receivingpongmeans the connection is working - Unsubscribe: When you no longer need it, send
{"method": "unsubscribe", "channels": ["liquidation_orders"]}
For general instructions on connecting, see WebSocket Getting Started.
Complete Example
Ignore the pong heartbeat response. For text ending in need upgrade plan, log the full rejected subscription string and continue receiving data from other subscriptions. Parse other messages as JSON; an unparseable message does not stop the receiver.
// Run on your server; Node.js 22 and above have WebSocket built in
const ws = new WebSocket(
"wss://open-ws.coinglass.com/ws-api?cg-api-key=" + process.env.COINGLASS_API_KEY
);
const upgradeSuffix = " need upgrade plan";
let heartbeat;
ws.onopen = () => {
ws.send(JSON.stringify({ method: "subscribe", channels: ["liquidation_orders"] }));
heartbeat = setInterval(() => {
if (ws.readyState === WebSocket.OPEN) ws.send("ping");
}, 20000);
};
ws.onclose = () => clearInterval(heartbeat);
ws.onmessage = (event) => {
const raw = event.data;
if (raw === "pong") return;
if (typeof raw !== "string") {
console.warn("Received a non-text message; ignored.");
return;
}
if (raw.endsWith(upgradeSuffix)) {
console.warn("Subscription not permitted:", raw.slice(0, -upgradeSuffix.length));
return;
}
let msg;
try {
msg = JSON.parse(raw);
} catch {
console.warn("Received an unparseable message; ignored.");
return;
}
if (msg && msg.channel === "liquidation_orders") console.log(msg.data);
};# Install first: pip install websockets
import asyncio
from contextlib import suppress
import json
import os
import websockets
URL = "wss://open-ws.coinglass.com/ws-api?cg-api-key=" + os.environ["COINGLASS_API_KEY"]
UPGRADE_SUFFIX = " need upgrade plan"
async def heartbeat(ws):
while True:
await asyncio.sleep(20)
await ws.send("ping")
async def main():
async with websockets.connect(URL) as ws:
await ws.send(json.dumps({"method": "subscribe", "channels": ["liquidation_orders"]}))
heartbeat_task = asyncio.create_task(heartbeat(ws))
try:
async for raw in ws:
if raw == "pong":
continue
if not isinstance(raw, str):
print("Received a non-text message; ignored.")
continue
if raw.endswith(UPGRADE_SUFFIX):
print("Subscription not permitted:", raw[:-len(UPGRADE_SUFFIX)])
continue
try:
msg = json.loads(raw)
except json.JSONDecodeError:
print("Received an unparseable message; ignored.")
continue
print(msg)
finally:
heartbeat_task.cancel()
with suppress(asyncio.CancelledError):
await heartbeat_task
asyncio.run(main())
Connect from your serverThe connection URL contains your API Key. Open the WebSocket connection on your server and forward the data to your frontend; do not connect directly from a web page.
Use Cases
Set a threshold on volume_usd, and when an amount exceeds it, push an alert to work groups on Telegram, Discord, Slack and similar platforms.
Show the latest liquidation orders in a scrolling feed, and summarize them per minute by exchange, coin and side.
A chain of liquidations in the same direction within a short time often comes with sharp volatility, and can be used to tighten risk controls or trigger strategies.
Write the pushed data to a database to build up a record of individual liquidations for post-event reviews and backtesting.
API Plans
Only the API plans marked Yes in the table below can call this endpoint. For the price of each plan, see API Plans.
| API Plan | Access |
|---|---|
| Hobbyist | ❌ No |
| Startup | ❌ No |
| Standard | ✅ Yes |
| Professional | ✅ Yes |
| Enterprise | ✅ Yes |
Other Channels
| Channel | Content |
|---|---|
| Spot Trades | Tick-by-tick trades in the spot market |
| Futures Trades | Tick-by-tick trades in the futures market |
| Futures Ticker Snapshot | Market snapshots of futures price, open interest and more |
FAQ
How do I recover after a disconnection, and is the data from that period lost?
When a network problem occurs, the connection is closed. Reconnect with gradually increasing intervals of 1, 2 and 4 seconds, and subscribe again once connected; you can use the REST Liquidation Orders endpoint to query data from the last 7 days.
How many connections can one API Key open at the same time?
There is no limit on the number of WebSocket connections.
What do 1 and 2 in the side field mean?
1 is a long liquidation and 2 is a short liquidation.
Learn More: Liquidations and Real-Time Data Push
What Is a Liquidation?
A liquidation is also called a forced close: when the margin in a futures account is no longer enough to maintain a position, the exchange forcibly closes that position. Long liquidations mostly happen during price declines, and short liquidations mostly during price rises.
How Do I Get Real-Time Bitcoin Liquidation Data?
Subscribe to the liquidation_orders channel and filter the received messages for base_asset equal to BTC to get real-time Bitcoin liquidation orders across the whole market; the same works for Ethereum, SOL and other coins.
What Is the Difference Between WebSocket Push and REST Polling?
Polling requires repeated requests that use up your quota, and can miss data between two requests; with WebSocket, the server pushes data as soon as an event happens, with lower latency and fewer requests.
Related Docs
- Coin Liquidation History: liquidation history API
- Pair Liquidation Heatmap (Model 1): liquidation heatmap API
- Pair Liquidation Map: liquidation map API
- Error Codes and Rate Limits: API rate limits
