CoinGlass Decrypt
TL;DR: Pure Python library (decrypt.py) to fetch and decrypt CoinGlass (capi.coinglass.com) internal API responses via two-round AES-128-ECB + gzip (v=0/1/2). Covers 136+ verified endpoints across crypto derivatives, funding rates, open interest, liquidations, RSI, ETF flows, and Hyperliquid with no API key and no browser required.
中文简介:纯 Python 实现的 CoinGlass 内部接口解密库(支持 v=0/1/2 双层 AES-128-ECB + gzip),无需 API Key 或无头浏览器,直接获取资金费率(funding rate)、持仓量(OI)、爆仓清算、RSI、ETF 流向与 Hyperliquid 等 136+ 加密市场数据。
Quick Start
pip install requests pycryptodome
git clone https://github.com/xeronsh/coinglass-decrypt.git
cd coinglass-decrypt
python example.py
Decryption Pipeline & Key Derivation
CoinGlass delivers a per-response encrypted AES key inside the user HTTP response header alongside a key-derivation selector header v. The first-layer key is Key0 = base64(seed)[:16]:
v | seed source | Notes |
|---|---|---|
0 | Request header cache-ts-v2 (ms timestamp) | Pass cache_ts=... to decrypt() |
1 | URL path (urlparse(url).path) | Universal across 136 active endpoints; pass url=... |
2 | Response header time | Pass time_header=... to decrypt() |
55/66/77 | Legacy webpack constants in _KEY_TABLE | Backward compatibility only |
Python API Reference
fetch_and_decrypt(url, params=None, timeout=30)
from decrypt import fetch_and_decrypt
data = fetch_and_decrypt(
"https://capi.coinglass.com/api/spot/rsi/list",
{"pageSize": 500, "pageNum": 1},
)
print(data["total"])
decrypt(encrypted_body, user_token_b64, v, url="", *, cache_ts="", time_header="")
from decrypt import decrypt
import requests
url = "https://capi.coinglass.com/api/spot/rsi/list"
resp = requests.get(
url,
params={"pageSize": 2},
headers={"encryption": "true", "Origin": "https://www.coinglass.com", "Referer": "https://www.coinglass.com"},
)
data = decrypt(resp.text, resp.headers["user"], resp.headers["v"], url=url, time_header=resp.headers.get("time", ""))
Verified Data Categories (136+ Endpoints)
| Category | Count | Highlights |
|---|---|---|
| Spot & Coins | 14 | RSI (15m–24h) for 400+ coins, markets, flows, unlock schedule |
| Futures & Liquidations | 16 | Liquidation chart/today, L/S ratio, big orders, OI, volume |
| Funding Rate & OI | 11 | Exchange rankings, averages, arbitrage, OI/Volume ratio |
| Options & Basis | 7 | Top OI/volume, strike pain, net premium heatmap, basis |
| ETF & Grayscale | 10 | ETF flows, BITO, GBTC history, shareholders |
| Hyperliquid & Derivatives | 8 | Vaults, top positions, exchange/DEX directories |
| Indices, Macro & TradFi | 50+ | CGDI, CGRI, Pi Cycle, AHR999, NUPL, calendar, TradFi |
See llms-full.txt or discovered_endpoints.py for the full endpoint list.
FAQ
How does CoinGlass encrypt its internal capi.coinglass.com API responses?
It applies two-round AES-128-ECB + gzip: the user response header holds a gzipped 16-char key encrypted with Key0 = base64(seed)[:16], and the JSON data field holds the gzipped JSON payload encrypted with that inner key.
Do I need a CoinGlass API key or headless browser?
No. Public web endpoints work with standard Python requests using encryption: true and cache-ts-v2 headers.
Why did decrypt() fail when v="1"?
For v="1", Key0 is derived from urlparse(url).path, so url must be passed to decrypt(..., url=url) (or use fetch_and_decrypt(url)).