Glassnode API Integration
Glassnode is the leading on-chain analytics platform. Their API provides hundreds of blockchain analysis metrics: wallet behavior, coin flows between exchanges and cold storage, miner metrics, hodler activity by holding duration.
Key Metrics for Traders
Exchange Flows — net coin inflow to/outflow from exchanges. Rising inflow historically correlates with selling pressure.
SOPR (Spent Output Profit Ratio) — ratio of realized price to purchase price for coins spent now. SOPR < 1 means coins selling at loss on average — often market bottom.
MVRV Ratio — Market Value to Realized Value. High MVRV (> 3.5) historically signals overheating; MVRV < 1 — strong undervaluation.
Hodler Net Position Change — long-term holder position change. LTH distribution (selling) at peaks.
API Connection
import httpx
class GlassnodeClient:
BASE_URL = "https://api.glassnode.com/v1/metrics"
def __init__(self, api_key: str):
self.api_key = api_key
self.session = httpx.AsyncClient(timeout=30.0)
async def get_metric(self, endpoint: str, asset: str = "BTC",
since: int = None, until: int = None,
interval: str = "24h") -> list[dict]:
params = {
"a": asset,
"api_key": self.api_key,
"i": interval,
}
if since:
params["s"] = since
if until:
params["u"] = until
resp = await self.session.get(
f"{self.BASE_URL}/{endpoint}",
params=params
)
resp.raise_for_status()
return resp.json()
Use in Trading Strategies
Glassnode metrics work on long-term horizons (days/weeks) but can filter short-term strategies: avoid long positions with extremely high MVRV, increase size when SOPR < 1.
async def compute_on_chain_composite_score(client: GlassnodeClient) -> float:
"""Returns 0 (bearish) to 1 (bullish)"""
sopr = (await client.get_metric("indicators/sopr"))[-1]["v"]
mvrv = (await client.get_metric("market/mvrv"))[-1]["v"]
netflow = (await client.get_metric("transactions/transfers_volume_exchanges_net"))[-1]["v"]
sopr_score = min(max((sopr - 0.95) / 0.1, 0), 1) # 0.95-1.05 range
mvrv_score = min(max((3.5 - mvrv) / 2.5, 0), 1) # 1.0-3.5 range
flow_score = 1.0 if netflow < 0 else 0.0 # outflow = bullish
return (sopr_score + mvrv_score + flow_score) / 3
Tiers and rate limits: free plan — limited metrics, daily data only. Advanced ($29/mo) — all metrics, hourly data. Institutional — minute data, bulk download. For production use caching: daily metrics update once daily, no need to query more often.







