/defillama-api
Free DeFi analytics across all chains — TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges
$ npx -y skills add agiprolabs/claude-trading-skills --skill defillama-api --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/defillama-api
Context preview
The summary Claude sees to decide when to auto-load this skill.
Free DeFi analytics across all chains — TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges
SKILL.md
defillama-api.SKILL.mdname: defillama-api
description: Free DeFi analytics across all chains — TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges
DeFiLlama API — DeFi Macro Analytics
DeFiLlama is the largest DeFi TVL aggregator. Its API is **free with no authentication** for most endpoints — covering TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges across all chains.
Quick Start
import httpx
# No auth required for free endpoints
BASE = "https://api.llama.fi"
COINS = "https://coins.llama.fi"
# Current TVL for a protocol
tvl = httpx.get(f"{BASE}/tvl/raydium").json()
print(f"Raydium TVL: ${tvl:,.0f}")
# Token prices (multi-chain)
resp = httpx.get(f"{COINS}/prices/current/solana:So11111111111111111111111111111111111111112")
sol_price = resp.json()["coins"]["solana:So11111111111111111111111111111111111111112"]["price"]Base URLs
| Service | Base URL | Auth | |---------|----------|------| | TVL / Protocols | `https://api.llama.fi` | Free | | Coin Prices | `https://coins.llama.fi` | Free | | Stablecoins | `https://stablecoins.llama.fi` | Free | | Yields | `https://yields.llama.fi` | Pro ($300/mo) | | Bridges | `https://bridges.llama.fi` | Free (list) / Pro (detail) | | Pro API | `https://pro-api.llama.fi/{KEY}/api/...` | Pro key in URL path |
**Rate limits**: ~500 requests per 5 minutes (free). Pro: 1,000 req/min, 1M calls/mo.
TVL & Protocol Data
# List all protocols with TVL
GET /protocols
# Returns: [{name, slug, tvl, chainTvls, change_1h, change_1d, change_7d, category, chains, ...}]
# Detailed protocol data with historical TVL
GET /protocol/{slug}
# Returns: Full object with tvl[], tokensInUsd{}, currentChainTvls{}, ...
# Simple current TVL number
GET /tvl/{slug}
# Returns: plain number (e.g., 150977324562.40)
# TVL for all chains
GET /v2/chains
# Returns: [{name, tvl, tokenSymbol, chainId, gecko_id}]
# Historical chain TVL
GET /v2/historicalChainTvl/{chain}
# chain: "Ethereum", "Solana", "Arbitrum", etc.
# Returns: [{date, tvl}] — date is unix timestamp (seconds)Token Prices
Coin identifiers use `{chain}:{address}` format:
- `solana:So11111111111111111111111111111111111111112` (SOL)
- `ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7` (USDT)
- `coingecko:bitcoin` (non-chain lookups)
# Current prices (batch)
GET /prices/current/{coins}
# coins: comma-separated identifiers
# Optional: searchWidth (default 4h)
# Returns: {coins: {id: {price, decimals, symbol, timestamp, confidence}}}
# Historical price at timestamp
GET /prices/historical/{timestamp}/{coins}
# timestamp: unix seconds
# Price chart
GET /chart/{coins}?period=1d&span=30
# period: 1d, 4h, 1h
# Returns: {coins: {id: {prices: [{timestamp, price}]}}}
# Price change percentage
GET /percentage/{coins}
# First recorded price
GET /prices/first/{coins}
# Block number at timestamp
GET /block/{chain}/{timestamp}Batch Historical Prices
# POST for multiple timestamps per coin
POST /batchHistorical
Body: {"coins": {"solana:So11...": [1709251200, 1709337600]}}DEX Volumes
# All DEXes aggregated
GET /overview/dexs
# Optional: excludeTotalDataChart=true, dataType=dailyVolume
# Chain-specific
GET /overview/dexs/{chain}
# chain: "Solana", "Ethereum", etc.
# Specific DEX
GET /summary/dexs/{protocol}
# Returns: {total24h, total7d, total30d, totalAllTime, totalDataChart, ...}Fees & Revenue
# All protocols
GET /overview/fees
# Optional: dataType=dailyFees|dailyRevenue|dailyUserFees
# Chain-specific
GET /overview/fees/{chain}
# Specific protocol
GET /summary/fees/{protocol}
# Returns: {total24h, total7d, methodology{}, totalDataChart[], ...}Stablecoins
# All stablecoins with supply data
GET https://stablecoins.llama.fi/stablecoins
# Returns: [{name, symbol, pegType, circulating, chainCirculating, price}]
# Historical market cap
GET https://stablecoins.llama.fi/stablecoincharts/all
# Chain-specific stablecoin data
GET https://stablecoins.llama.fi/stablecoincharts/{chain}
# Stablecoin prices (deviation tracking)
GET https://stablecoins.llama.fi/stablecoinpricesBridges
# List all bridges
GET https://bridges.llama.fi/bridges
# Optional: includeChains=true
# Returns: {bridges: [{name, volume stats, chains, ...}]}Common Patterns
Protocol TVL Comparison
def compare_protocol_tvl(slugs: list[str]) -> list[dict]:
"""Compare TVL across protocols."""
results = []
for slug in slugs:
resp = httpx.get(f"https://api.llama.fi/tvl/{slug}", timeout=15.0)
if resp.status_code == 200:
results.append({"protocol": slug, "tvl": resp.json()})
return sorted(results, key=lambda x: x["tvl"], reverse=True)Multi-Token Price Lookup
def get_solana_prices(mints: list[str]) -> dict[str, float]:
"""Get USD prices for Solana tokens via DeFiLlama."""
coins = ",".join(f"solana:{m}" for m in mints)
resp = httpx.get(f"https://coins.llama.fi/prices/current/{coins}")
data = resp.json().get("coins", {})
return {
mint: data[f"solana:{mint}"]["price"]
for mint in mints
if f"solana:{mint}" in data
}Solana DeFi Overview
def solana_defi_snapshot() -> dict:
"""Get a snapshot of Solana DeFi activity."""
chain_tvl = httpx.get("https://api.llama.fi/v2/chains").json()
sol_tvl = next((c["tvl"] for c in chain_tvl if c["name"] == "Solana"), 0)
dex_vol = httpx.get("https://api.llama.fi/overview/dexs/Solana").json()
fees = httpx.get("https://api.llama.fi/overview/fees/Solana").json()
return {
"tvl": sol_tvl,
"dex_volume_24h": dex_vol.get("total24h", 0),
"fees_24h": fees.get("total24h", 0),
}Historical Price Analysis
def price_at_date(coin: str, date_str: str) -> float:
"""Get token price at a specific date.
Args:
coin: DeFiLlama coin ID (e.g., 'solana:SoRead more
name: defillama-api description: Free DeFi analytics across all chains — TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges
DeFiLlama API — DeFi Macro Analytics
DeFiLlama is the largest DeFi TVL aggregator. Its API is **free with no authentication** for most endpoints — covering TVL, token prices, DEX volumes, fees/revenue, stablecoins, and bridges across all chains.
Quick Start
import httpx
# No auth required for free endpoints
BASE = "https://api.llama.fi"
COINS = "https://coins.llama.fi"
# Current TVL for a protocol
tvl = httpx.get(f"{BASE}/tvl/raydium").json()
print(f"Raydium TVL: ${tvl:,.0f}")
# Token prices (multi-chain)
resp = httpx.get(f"{COINS}/prices/current/solana:So11111111111111111111111111111111111111112")
sol_price = resp.json()["coins"]["solana:So11111111111111111111111111111111111111112"]["price"]Base URLs
| Service | Base URL | Auth | |---------|----------|------| | TVL / Protocols | `https://api.llama.fi` | Free | | Coin Prices | `https://coins.llama.fi` | Free | | Stablecoins | `https://stablecoins.llama.fi` | Free | | Yields | `https://yields.llama.fi` | Pro ($300/mo) | | Bridges | `https://bridges.llama.fi` | Free (list) / Pro (detail) | | Pro API | `https://pro-api.llama.fi/{KEY}/api/...` | Pro key in URL path |
**Rate limits**: ~500 requests per 5 minutes (free). Pro: 1,000 req/min, 1M calls/mo.
TVL & Protocol Data
# List all protocols with TVL
GET /protocols
# Returns: [{name, slug, tvl, chainTvls, change_1h, change_1d, change_7d, category, chains, ...}]
# Detailed protocol data with historical TVL
GET /protocol/{slug}
# Returns: Full object with tvl[], tokensInUsd{}, currentChainTvls{}, ...
# Simple current TVL number
GET /tvl/{slug}
# Returns: plain number (e.g., 150977324562.40)
# TVL for all chains
GET /v2/chains
# Returns: [{name, tvl, tokenSymbol, chainId, gecko_id}]
# Historical chain TVL
GET /v2/historicalChainTvl/{chain}
# chain: "Ethereum", "Solana", "Arbitrum", etc.
# Returns: [{date, tvl}] — date is unix timestamp (seconds)Token Prices
Coin identifiers use `{chain}:{address}` format:
- `solana:So11111111111111111111111111111111111111112` (SOL)
- `ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7` (USDT)
- `coingecko:bitcoin` (non-chain lookups)
# Current prices (batch)
GET /prices/current/{coins}
# coins: comma-separated identifiers
# Optional: searchWidth (default 4h)
# Returns: {coins: {id: {price, decimals, symbol, timestamp, confidence}}}
# Historical price at timestamp
GET /prices/historical/{timestamp}/{coins}
# timestamp: unix seconds
# Price chart
GET /chart/{coins}?period=1d&span=30
# period: 1d, 4h, 1h
# Returns: {coins: {id: {prices: [{timestamp, price}]}}}
# Price change percentage
GET /percentage/{coins}
# First recorded price
GET /prices/first/{coins}
# Block number at timestamp
GET /block/{chain}/{timestamp}Batch Historical Prices
# POST for multiple timestamps per coin
POST /batchHistorical
Body: {"coins": {"solana:So11...": [1709251200, 1709337600]}}DEX Volumes
# All DEXes aggregated
GET /overview/dexs
# Optional: excludeTotalDataChart=true, dataType=dailyVolume
# Chain-specific
GET /overview/dexs/{chain}
# chain: "Solana", "Ethereum", etc.
# Specific DEX
GET /summary/dexs/{protocol}
# Returns: {total24h, total7d, total30d, totalAllTime, totalDataChart, ...}Fees & Revenue
# All protocols
GET /overview/fees
# Optional: dataType=dailyFees|dailyRevenue|dailyUserFees
# Chain-specific
GET /overview/fees/{chain}
# Specific protocol
GET /summary/fees/{protocol}
# Returns: {total24h, total7d, methodology{}, totalDataChart[], ...}Stablecoins
# All stablecoins with supply data
GET https://stablecoins.llama.fi/stablecoins
# Returns: [{name, symbol, pegType, circulating, chainCirculating, price}]
# Historical market cap
GET https://stablecoins.llama.fi/stablecoincharts/all
# Chain-specific stablecoin data
GET https://stablecoins.llama.fi/stablecoincharts/{chain}
# Stablecoin prices (deviation tracking)
GET https://stablecoins.llama.fi/stablecoinpricesBridges
# List all bridges
GET https://bridges.llama.fi/bridges
# Optional: includeChains=true
# Returns: {bridges: [{name, volume stats, chains, ...}]}Common Patterns
Protocol TVL Comparison
def compare_protocol_tvl(slugs: list[str]) -> list[dict]:
"""Compare TVL across protocols."""
results = []
for slug in slugs:
resp = httpx.get(f"https://api.llama.fi/tvl/{slug}", timeout=15.0)
if resp.status_code == 200:
results.append({"protocol": slug, "tvl": resp.json()})
return sorted(results, key=lambda x: x["tvl"], reverse=True)Multi-Token Price Lookup
def get_solana_prices(mints: list[str]) -> dict[str, float]:
"""Get USD prices for Solana tokens via DeFiLlama."""
coins = ",".join(f"solana:{m}" for m in mints)
resp = httpx.get(f"https://coins.llama.fi/prices/current/{coins}")
data = resp.json().get("coins", {})
return {
mint: data[f"solana:{mint}"]["price"]
for mint in mints
if f"solana:{mint}" in data
}Solana DeFi Overview
def solana_defi_snapshot() -> dict:
"""Get a snapshot of Solana DeFi activity."""
chain_tvl = httpx.get("https://api.llama.fi/v2/chains").json()
sol_tvl = next((c["tvl"] for c in chain_tvl if c["name"] == "Solana"), 0)
dex_vol = httpx.get("https://api.llama.fi/overview/dexs/Solana").json()
fees = httpx.get("https://api.llama.fi/overview/fees/Solana").json()
return {
"tvl": sol_tvl,
"dex_volume_24h": dex_vol.get("total24h", 0),
"fees_24h": fees.get("total24h", 0),
}Historical Price Analysis
def price_at_date(coin: str, date_str: str) -> float:
"""Get token price at a specific date.
Args:
coin: DeFiLlama coin ID (e.g., 'solana:SoA comprehensive collection of 67 ready-to-use trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools.
Repo: agiprolabs/claude-trading-skills
Other skills on trading-skills.
- /backtrader
Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators
Open skill - /birdeye-api
Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity
Open skill - /coingecko-api
Broad crypto market data from CoinGecko covering 13,000+ tokens. Global market stats, historical price data going back years, exchange volumes, trending tokens, and category filters. Best for macro analysis and long-term historical data.
Open skill - /cointegration-analysis
Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis
Open skill - /copy-trading
Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading
Open skill - /correlation-analysis
Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation
Open skill

