defillama
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDefiLlama API
DefiLlama API
Trit: -1 (MINUS - Validator/Data Source)
Color: #4A90D9 (Cold blue, 210°)
Comprehensive DeFi data from DefiLlama's API ecosystem.
Trit: -1 (MINUS - 验证器/数据源)
Color: #4A90D9 (冷蓝色, 210°)
来自DefiLlama API生态的全面DeFi数据。
Matching Keywords (intent triggers)
匹配关键词(意图触发条件)
Use this skill when users ask about any of the following:
- TVL: TVL ranking, protocol TVL, chain TVL, TVL changes, DeFi market share
- Stablecoin yield: stablecoin yield, USDC/USDT APY, low-risk yield pools, safe yield, fixed-income-like DeFi
- Yield / Farming: APY ranking, yield pool screening, vault yield, lending APY, borrow rates, LSD/LRT yield
- DEX / Fees / Revenue: DEX volume, protocol fees, protocol revenue, revenue growth, which DEX revenue is growing fastest
- Flows / Rotation: capital flows, chain inflow/outflow, stablecoin netflow, liquidity rotation
- Protocol Research: protocol fundamentals, multi-protocol comparison, sector comparison, DeFi snapshot/report
Typical user prompts this skill should match:
- “Which DEX has seen the strongest revenue growth recently?”
- “Find me some low-risk stablecoin yield options with decent returns.”
- “Create a DeFi market snapshot for today (TVL / volume / fees).”
- “Compare ETH vs SOL on-chain flow changes over the last 30 days.”
当用户询问以下任意内容时可使用该技能:
- TVL: TVL排名、协议TVL、公链TVL、TVL变动、DeFi市场份额
- 稳定币收益: 稳定币收益、USDC/USDT APY、低风险收益池、安全收益、类固定收益DeFi
- 收益 / 挖矿: APY排名、收益池筛选、金库收益、借贷APY、借款利率、LSD/LRT收益
- DEX / 手续费 / 收入: DEX交易量、协议手续费、协议收入、收入增长、哪款DEX收入增长最快
- 资金流向 / 轮动: 资金流向、公链流入/流出、稳定币净流量、流动性轮动
- 协议研究: 协议基本面、多协议对比、赛道对比、DeFi快照/报告
该技能应匹配的典型用户提问:
- “最近哪款DEX的收入增长最强劲?”
- “给我找一些收益不错的低风险稳定币收益选项。”
- “生成今日DeFi市场快照(TVL / 交易量 / 手续费)。”
- “对比过去30天ETH和SOL的链上流量变化。”
Base URLs
基础URL
| API | Base URL | Auth |
|---|---|---|
| Free API | | None (no key needed) |
| Pro API | | Key in path |
| Bridge API | | None |
Key rule: Usefor all free endpoints (TVL, chains, DEX, fees, prices). Usehttps://api.llama.fiONLY for pro endpoints (yields, derivatives, emissions). Env var:https://pro-api.llama.fi/{API_KEY}— used in pro URL path, NOT as HTTP header.DEFILLAMA_API_KEY
| API | 基础URL | 鉴权 |
|---|---|---|
| 免费API | | 无需鉴权(不需要密钥) |
| 专业版API | | 密钥放在路径 |
| 跨链桥API | | 无需鉴权 |
核心规则: 所有免费端点(TVL、公链、DEX、手续费、价格)使用仅专业版端点(收益、衍生品、代币释放)使用https://api.llama.fi环境变量:https://pro-api.llama.fi/{API_KEY}—— 用于专业版URL路径中,不作为HTTP请求头传递。DEFILLAMA_API_KEY
Most Common Endpoints (Start Here)
最常用端点(入门首选)
For 90% of DeFi analytics tasks, use these free endpoints ():
api.llama.fi| Task | Endpoint | Example |
|---|---|---|
| TVL Top N protocols | | Sort by |
| Single protocol detail | | e.g. |
| Chain TVL history | | |
| DEX volumes | | |
| Protocol fees | | |
| All chains TVL | | Sum |
⚠️ Pro endpoints (,/yields/*, etc.) require/emissionsin the URL path.DEFILLAMA_API_KEY
90%的DeFi分析任务都可以使用以下免费端点()完成:
api.llama.fi| 任务 | 端点 | 示例 |
|---|---|---|
| TVL排名前N的协议 | | 按 |
| 单个协议详情 | | 例如 |
| 公链TVL历史数据 | | 取 |
| DEX交易量 | | 取 |
| 协议手续费 | | 取 |
| 所有公链TVL | | 累加 |
⚠️ 专业版端点(、/yields/*等)需要在URL路径中传入/emissions。DEFILLAMA_API_KEY
Proxy Requirement (sc-proxy)
代理要求(sc-proxy)
When using fake API keys (for example ), requests must go through sc-proxy so the key can be replaced upstream.
fake-defillama-key-12345- Env key name:
DEFILLAMA_API_KEY - Auto proxy detection envs: ,
PROXY_HOSTPROXY_PORT - If /
HTTP_PROXYare unset, direct requests may hit upstream and return key errors.HTTPS_PROXY
当使用测试API密钥(例如)时,请求必须走sc-proxy,上游服务会自动替换有效密钥。
fake-defillama-key-12345- 环境变量名:
DEFILLAMA_API_KEY - 自动代理检测环境变量: 、
PROXY_HOSTPROXY_PORT - 如果未设置/
HTTP_PROXY,直接请求上游会返回密钥错误。HTTPS_PROXY
Python template (recommended)
Python模板(推荐)
python
import os
import requests
host = os.getenv("PROXY_HOST")
port = os.getenv("PROXY_PORT")
session = requests.Session()
if host and port:
if ":" in host and not host.startswith("["):
host = f"[{host}]" # IPv6-safe
proxy = f"http://{host}:{port}"
session.proxies.update({"http": proxy, "https": proxy})python
import os
import requests
host = os.getenv("PROXY_HOST")
port = os.getenv("PROXY_PORT")
session = requests.Session()
if host and port:
if ":" in host and not host.startswith("["):
host = f"[{host}]" # IPv6-safe
proxy = f"http://{host}:{port}"
session.proxies.update({"http": proxy, "https": proxy})Free endpoint (no key needed):
Free endpoint (no key needed):
r_free = session.get("https://api.llama.fi/protocols", timeout=25)
print("Free:", r_free.status_code)
r_free = session.get("https://api.llama.fi/protocols", timeout=25)
print("Free:", r_free.status_code)
Pro endpoint (key in URL path):
Pro endpoint (key in URL path):
api_key = os.environ["DEFILLAMA_API_KEY"]
r_pro = session.get(f"https://pro-api.llama.fi/{api_key}/yields/pools", timeout=25)
print("Pro:", r_pro.status_code)
undefinedapi_key = os.environ["DEFILLAMA_API_KEY"]
r_pro = session.get(f"https://pro-api.llama.fi/{api_key}/yields/pools", timeout=25)
print("Pro:", r_pro.status_code)
undefinedQuick test commands
快速测试命令
bash
set -a && source .env && set +a
python3 - << 'PY'
import os, requests
s = requests.Session()
host, port = os.getenv('PROXY_HOST'), os.getenv('PROXY_PORT')
if host and port:
if ':' in host and not host.startswith('['):
host = f'[{host}]'
p = f'http://{host}:{port}'
s.proxies.update({'http': p, 'https': p})bash
set -a && source .env && set +a
python3 - << 'PY'
import os, requests
s = requests.Session()
host, port = os.getenv('PROXY_HOST'), os.getenv('PROXY_PORT')
if host and port:
if ':' in host and not host.startswith('['):
host = f'[{host}]'
p = f'http://{host}:{port}'
s.proxies.update({'http': p, 'https': p})Free endpoint
Free endpoint
r1 = s.get('https://api.llama.fi/protocols', timeout=25)
print('free /protocols:', r1.status_code)
r1 = s.get('https://api.llama.fi/protocols', timeout=25)
print('free /protocols:', r1.status_code)
Pro endpoint
Pro endpoint
k = os.environ['DEFILLAMA_API_KEY']
r2 = s.get(f'https://pro-api.llama.fi/{k}/yields/pools', timeout=25)
print('pro /yields/pools:', r2.status_code)
PY
undefinedk = os.environ['DEFILLAMA_API_KEY']
r2 = s.get(f'https://pro-api.llama.fi/{k}/yields/pools', timeout=25)
print('pro /yields/pools:', r2.status_code)
PY
undefinedQuick Reference
快速参考
TVL & Protocols
TVL与协议
bash
undefinedbash
undefinedAll protocols with TVL
所有带TVL的协议
GET /protocols
GET /protocols
Single protocol detail
单个协议详情
GET /protocol/{slug}
GET /protocol/{slug}
Chain TVL
公链TVL
GET /v2/chains
GET /v2/historicalChainTvl/{chain}
undefinedGET /v2/chains
GET /v2/historicalChainTvl/{chain}
undefinedPrices
价格
bash
undefinedbash
undefinedCurrent prices (chain:address format)
当前价格(格式:公链:地址)
GET /coins/prices/current/{coins}
GET /coins/prices/current/{coins}
Historical
历史价格
GET /coins/prices/historical/{timestamp}/{coins}
GET /coins/prices/historical/{timestamp}/{coins}
Chart data
图表数据
GET /coins/chart/{coins}?period=30d
undefinedGET /coins/chart/{coins}?period=30d
undefinedYields (Pro)
收益(专业版)
bash
GET /yields/pools # All yield pools
GET /yields/chart/{pool} # Pool history
GET /yields/poolsBorrow # Borrow rates
GET /yields/perps # Perp funding
GET /yields/lsdRates # LSD ratesbash
GET /yields/pools # 所有收益池
GET /yields/chart/{pool} # 收益池历史数据
GET /yields/poolsBorrow # 借款利率
GET /yields/perps # 永续合约资金费率
GET /yields/lsdRates # LSD收益率Volume
交易量
bash
GET /overview/dexs?excludeChart=true # DEX volumes (recommended)
GET /overview/dexs/{chain}?excludeChart=true # Chain DEX
GET /summary/dexs/{protocol} # Protocol detail
GET /overview/options?excludeChart=true # Options
GET /overview/derivatives?excludeChart=true # Derivatives (Pro)bash
GET /overview/dexs?excludeChart=true # DEX交易量(推荐)
GET /overview/dexs/{chain}?excludeChart=true # 单公链DEX数据
GET /summary/dexs/{protocol} # 协议详情
GET /overview/options?excludeChart=true # 期权数据
GET /overview/derivatives?excludeChart=true # 衍生品数据(专业版)Fees & Revenue
手续费与收入
bash
GET /overview/fees?excludeChart=true # All fees/revenue (recommended)
GET /overview/fees/{chain}?excludeChart=true # Chain fees
GET /summary/fees/{protocol} # Protocol feesbash
GET /overview/fees?excludeChart=true # 所有手续费/收入(推荐)
GET /overview/fees/{chain}?excludeChart=true # 单公链手续费
GET /summary/fees/{protocol} # 协议手续费dataType: dailyFees | dailyRevenue | dailyHoldersRevenue
dataType可选: dailyFees | dailyRevenue | dailyHoldersRevenue
undefinedundefinedBridges
跨链桥
bash
undefinedbash
undefinedBase: https://bridges.llama.fi
基础地址: https://bridges.llama.fi
GET /bridges # All bridges
GET /bridge/{id} # Bridge detail
GET /bridgevolume/{chain} # Volume by chain
GET /transactions/{id} # Bridge txs
undefinedGET /bridges # 所有跨链桥
GET /bridge/{id} # 跨链桥详情
GET /bridgevolume/{chain} # 按公链统计的交易量
GET /transactions/{id} # 跨链桥交易记录
undefinedDAT (Digital Asset Treasury)
DAT(数字资产国库)
bash
GET /dat/institutions # All institutions
GET /dat/institutions/{symbol} # e.g., MSTRbash
GET /dat/institutions # 所有机构
GET /dat/institutions/{symbol} # 例如 MSTRUsage Script
使用脚本
clojure
;; See scripts/defillama.bb for full implementation
(require '[defillama :as dl])
;; TVL
(dl/protocols)
(dl/protocol "aave")
(dl/chain-tvl "Ethereum")
;; Prices
(dl/price "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
(dl/price-chart "coingecko:ethereum" {:period "30d"})
;; Yields
(dl/yield-pools)
(dl/pool-chart "747c1d2a-c668-4682-b9f9-296708a3dd90")
;; Volumes
(dl/dex-overview)
(dl/dex-protocol "uniswap")
;; Fees
(dl/fees-overview)
(dl/fees-protocol "hyperliquid")clojure
;; See scripts/defillama.bb for full implementation
(require '[defillama :as dl])
;; TVL
(dl/protocols)
(dl/protocol "aave")
(dl/chain-tvl "Ethereum")
;; Prices
(dl/price "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
(dl/price-chart "coingecko:ethereum" {:period "30d"})
;; Yields
(dl/yield-pools)
(dl/pool-chart "747c1d2a-c668-4682-b9f9-296708a3dd90")
;; Volumes
(dl/dex-overview)
(dl/dex-protocol "uniswap")
;; Fees
(dl/fees-overview)
(dl/fees-protocol "hyperliquid")Endpoint Categories
端点分类
Free Endpoints
免费端点
- ,
/protocols,/protocol/{slug}/tvl/{slug} - ,
/v2/chains/v2/historicalChainTvl - ,
/coins/prices/*/coins/chart/* - ,
/overview/dexs/overview/options - ,
/overview/fees/summary/fees/*
- ,
/protocols,/protocol/{slug}/tvl/{slug} - ,
/v2/chains/v2/historicalChainTvl - ,
/coins/prices/*/coins/chart/* - ,
/overview/dexs/overview/options - ,
/overview/fees/summary/fees/*
Pro Endpoints (API Key Required)
专业版端点(需要API密钥)
- - All yield endpoints (stablecoin pools, APY ranking, borrow/perps/LSD)
/yields/* /overview/derivatives/tokenProtocols/{symbol}/inflows/{protocol}/{timestamp}/chainAssets- ,
/emissions/emission/{protocol} - ,
/categories,/forks/oracles - ,
/entities/treasuries - ,
/hacks/raises - ,
/etfs/*/dat/* - Bridge endpoints on bridges.llama.fi
- - 所有收益相关端点(稳定币池、APY排名、借款/永续合约/LSD)
/yields/* /overview/derivatives/tokenProtocols/{symbol}/inflows/{protocol}/{timestamp}/chainAssets- ,
/emissions/emission/{protocol} - ,
/categories,/forks/oracles - ,
/entities/treasuries - ,
/hacks/raises - ,
/etfs/*/dat/* - bridges.llama.fi上的跨链桥端点
Response Patterns
返回格式示例
TVL Response
TVL返回
json
{"id": "2269", "name": "Aave", "tvl": 5200000000, "chains": ["Ethereum"]}json
{"id": "2269", "name": "Aave", "tvl": 5200000000, "chains": ["Ethereum"]}Price Response
价格返回
json
{"coins": {"ethereum:0x...": {"price": 0.999, "symbol": "USDC", "confidence": 0.99}}}json
{"coins": {"ethereum:0x...": {"price": 0.999, "symbol": "USDC", "confidence": 0.99}}}Yield Pool Response
收益池返回
json
{"pool": "uuid", "chain": "Ethereum", "project": "aave-v3", "apy": 3.5, "tvlUsd": 1500000000}json
{"pool": "uuid", "chain": "Ethereum", "project": "aave-v3", "apy": 3.5, "tvlUsd": 1500000000}GF(3) Integration
GF(3) 集成
This skill serves as MINUS (-1) validator in triads:
- Provides authoritative DeFi data
- Validates protocol metrics
- Constrains analysis with real data
Compose with:
- (+1): Execute based on data
aptos-agent - (0): Enrich with web context
exa-search
该技能在三元组中作为MINUS (-1) 验证器:
- 提供权威DeFi数据
- 验证协议指标
- 用真实数据约束分析
可搭配以下技能使用:
- (+1): 基于数据执行操作
aptos-agent - (0): 用网页上下文丰富数据
exa-search
Output Format Guidelines (Chinese/English Queries)
输出格式指南(支持中/英文查询)
Always format DeFi data responses as human-readable markdown. Support both Chinese and English queries.
始终将DeFi数据返回为人类可读的markdown格式,支持中英文查询。
Number Formatting
数字格式化
- TVL ≥ $1B → ; TVL ≥ $1M →
$X.XXB$XXXM - APY →
XX.X% - 24h changes → or
+X.X%-X.X% - Always include units: ,
$,%(billion),B(million)M
- TVL ≥ $1B → 格式为;TVL ≥ $1M → 格式为
$X.XXB$XXXM - APY → 格式为
XX.X% - 24小时变动 → 格式为或
+X.X%-X.X% - 始终保留单位:、
$、%(十亿)、B(百万)M
Recommended Output Templates
推荐输出模板
TVL Leaderboard:
markdown
| # | Protocol | TVL | Chains |
|---|--------------|-----|-----------|
| 1 | Aave V3 | $24.7B | Ethereum, Arbitrum |Yield Pools:
markdown
| Pool | APY | TVL | Risk |
|---------|-----|-----|---------|
| USDC | 5.2% | $500M | ✅ Low risk |Market Snapshot:
markdown
| Metric | Value |
|------------|-----------|
| Total TVL | $96B |
| DEX 24h volume | $5.7B |
| Fees 24h | $49M |TVL排行榜:
markdown
| # | 协议 | TVL | 部署公链 |
|---|--------------|-----|-----------|
| 1 | Aave V3 | $24.7B | Ethereum, Arbitrum |收益池:
markdown
| 收益池 | APY | TVL | 风险等级 |
|---------|-----|-----|---------|
| USDC | 5.2% | $500M | ✅ 低风险 |市场快照:
markdown
| 指标 | 数值 |
|------------|-----------|
| 总TVL | $96B |
| DEX 24小时交易量 | $5.7B |
| 24小时总手续费 | $49M |Risk Labels
风险标签
Always include risk indicators for yield pools:
- — stable APY < 20%, no IL risk
✅ Low risk - — APY 20-100%, or IL risk present
⚠️ Medium risk - — APY > 100% (likely incentive-driven, unsustainable)
🔴 High risk
收益池返回必须包含风险标识:
- — 稳定APY < 20%,无常损失风险
✅ 低风险 - — APY 20-100%,或存在无常损失风险
⚠️ 中风险 - — APY > 100%(通常为激励驱动,不可持续)
🔴 高风险
Tip: excludeChart Parameter
提示:excludeChart参数
For volume/fee overview endpoints, always add to reduce response size:
?excludeChart=truebash
GET /overview/dexs?excludeChart=true # DEX volumes (much faster)
GET /overview/fees?excludeChart=true # Fee data (much faster)查询交易量/手续费概览端点时,始终添加以减少返回体积:
?excludeChart=truebash
GET /overview/dexs?excludeChart=true # DEX交易量(响应速度快很多)
GET /overview/fees?excludeChart=true # 手续费数据(响应速度快很多)Common Pitfalls & Gotchas
常见陷阱与注意事项
1. Wrong Base URL for Free Endpoints
1. 免费端点用错基础URL
❌ WRONG: → returns 404 "Path needs to start with /yields/..."
✅ CORRECT:
https://pro-api.llama.fi/protocolshttps://api.llama.fi/protocolsFree endpoints NEVER go through .
pro-api.llama.fi❌ 错误: → 返回404 "Path needs to start with /yields/..."
✅ 正确:
https://pro-api.llama.fi/protocolshttps://api.llama.fi/protocols免费端点永远不会走域名。
pro-api.llama.fi2. Pro Endpoint Without API Key
2. 专业版端点未带API密钥
❌ WRONG: → 401 or wrong route
✅ CORRECT:
https://pro-api.llama.fi/yields/poolshttps://pro-api.llama.fi/{DEFILLAMA_API_KEY}/yields/poolsThe API key is in the URL path, not in a header.
❌ 错误: → 返回401或路由错误
✅ 正确:
https://pro-api.llama.fi/yields/poolshttps://pro-api.llama.fi/{DEFILLAMA_API_KEY}/yields/poolsAPI密钥放在URL路径中,不是请求头里。
3. Missing excludeChart=true
for Volume/Fee Endpoints
excludeChart=true3. 交易量/手续费端点未加excludeChart=true
excludeChart=trueWithout this param, returns large chart history arrays.
Always add for summary queries.
/overview/dexs?excludeChart=true不带该参数时,会返回大量历史图表数组,汇总查询时请始终添加。
/overview/dexs?excludeChart=true4. Handling TVL Null Values
4. 处理TVL空值
When sorting protocols by TVL, filter first:
python
valid = [p for p in protocols if isinstance(p.get('tvl'), (int, float)) and p['tvl'] > 0]按TVL排序协议时,请先过滤无效值:
python
valid = [p for p in protocols if isinstance(p.get('tvl'), (int, float)) and p['tvl'] > 0]5. Stablecoins vs TVL
5. 稳定币与TVL的区别
DefiLlama's chain TVL includes ALL DeFi assets, not just stablecoins.
For stablecoin-specific flows, use the API (separate from pro-api).
When asked about "stablecoin flows", the chain TVL change is a reasonable proxy.
stablecoins.llama.fiDefiLlama的公链TVL包含所有DeFi资产,不止稳定币。如果需要稳定币专属流量数据,请使用 API(与专业版API独立)。当用户询问“稳定币流量”时,公链TVL变化是合理的近似指标。
stablecoins.llama.fi6. Yields Pool UUID
6. 收益池UUID
The field in is a UUID like .
Use this UUID (not token address) for history.
pool/yields/pools"747c1d2a-c668-4682-b9f9-296708a3dd90"/yields/chart/{pool}/yields/poolspool"747c1d2a-c668-4682-b9f9-296708a3dd90"/yields/chart/{pool}7. Stablecoin Yield Screening Baseline
7. 稳定币收益筛选基准
For “conservative stablecoin yield” requests, start with this baseline filter:
stablecoin == truetvlUsd >= 50_000_000- between
apyand2(drop extreme incentive spikes)20 ilRisk == "no"- Prefer for conservative profiles
exposure == "single"
当用户请求“稳健稳定币收益”时,可使用以下基准过滤:
stablecoin == truetvlUsd >= 50_000_000- 介于
apy和2之间(排除极端激励波动)20 ilRisk == "no"- 稳健型需求优先选择的单资产池子
exposure == "single"
Workflow Examples (Agent Recipes)
工作流示例(Agent 方案)
Recipe 1: DeFi TVL Top 10 (1 call)
方案1: DeFi TVL Top10(1次请求)
python
r = requests.get("https://api.llama.fi/protocols")
protocols = r.json()
top10 = sorted([p for p in protocols if p.get('tvl',0) > 0], key=lambda x: x['tvl'], reverse=True)[:10]python
r = requests.get("https://api.llama.fi/protocols")
protocols = r.json()
top10 = sorted([p for p in protocols if p.get('tvl',0) > 0], key=lambda x: x['tvl'], reverse=True)[:10]Output: markdown table with | # | Protocol | TVL | Chain |
Output: markdown table with | # | Protocol | TVL | Chain |
undefinedundefinedRecipe 2: ETH vs SOL 30-day TVL comparison (2 calls)
方案2: ETH vs SOL 30天TVL对比(2次请求)
python
r1 = requests.get("https://api.llama.fi/v2/historicalChainTvl/Ethereum")
r2 = requests.get("https://api.llama.fi/v2/historicalChainTvl/Solana")python
r1 = requests.get("https://api.llama.fi/v2/historicalChainTvl/Ethereum")
r2 = requests.get("https://api.llama.fi/v2/historicalChainTvl/Solana")Filter last 30d: [d for d in r1.json() if d['date'] >= time.time() - 30*86400]
Filter last 30d: [d for d in r1.json() if d['date'] >= time.time() - 30*86400]
Output: | Chain | TVL 30d ago | TVL today | Change % |
Output: | Chain | TVL 30d ago | TVL today | Change % |
undefinedundefinedRecipe 3: Stablecoin yield shortlist (1 call)
方案3: 稳定币收益候选列表(1次请求)
python
r = requests.get(f"https://pro-api.llama.fi/{API_KEY}/yields/pools")
raw = r.json()
pools = raw.get('data', raw) if isinstance(raw, dict) else raw
safe = [p for p in pools
if p.get('stablecoin') is True
and (p.get('tvlUsd') or 0) >= 50_000_000
and (p.get('apy') or 0) >= 2
and (p.get('apy') or 0) <= 20
and p.get('ilRisk') == 'no']
top = sorted(safe, key=lambda x: x.get('apy', 0), reverse=True)[:10]python
r = requests.get(f"https://pro-api.llama.fi/{API_KEY}/yields/pools")
raw = r.json()
pools = raw.get('data', raw) if isinstance(raw, dict) else raw
safe = [p for p in pools
if p.get('stablecoin') is True
and (p.get('tvlUsd') or 0) >= 50_000_000
and (p.get('apy') or 0) >= 2
and (p.get('apy') or 0) <= 20
and p.get('ilRisk') == 'no']
top = sorted(safe, key=lambda x: x.get('apy', 0), reverse=True)[:10]Output: | Project | Chain | Symbol | APY | TVL | Risk |
Output: | Project | Chain | Symbol | APY | TVL | Risk |
undefinedundefinedRecipe 4: DeFi Market Snapshot (3 calls)
方案4: DeFi市场快照(3次请求)
python
chains = requests.get("https://api.llama.fi/v2/chains").json()
dexs = requests.get("https://api.llama.fi/overview/dexs?excludeChart=true").json()
fees = requests.get("https://api.llama.fi/overview/fees?excludeChart=true").json()python
chains = requests.get("https://api.llama.fi/v2/chains").json()
dexs = requests.get("https://api.llama.fi/overview/dexs?excludeChart=true").json()
fees = requests.get("https://api.llama.fi/overview/fees?excludeChart=true").json()total_tvl = sum(c['tvl'] for c in chains if isinstance(c.get('tvl'), (int,float)))
total_tvl = sum(c['tvl'] for c in chains if isinstance(c.get('tvl'), (int,float)))
Output: snapshot table with TVL, DEX 24h vol, Fee 24h
Output: snapshot table with TVL, DEX 24h vol, Fee 24h
undefinedundefinedRecipe 5: Protocol TVL spike analysis (2 calls)
方案5: 协议TVL异动分析(2次请求)
python
r1 = requests.get("https://api.llama.fi/protocols") # find protocol with big change_1d
r2 = requests.get(f"https://api.llama.fi/protocol/{slug}") # get chainTvls detailpython
r1 = requests.get("https://api.llama.fi/protocols") # find protocol with big change_1d
r2 = requests.get(f"https://api.llama.fi/protocol/{slug}") # get chainTvls detailOutput: | Hypothesis | Explanation | How to verify | (table + step-by-step verification)
Output: | Hypothesis | Explanation | How to verify | (table + step-by-step verification)
undefinedundefinedStablecoin Data
稳定币数据
For stablecoin-specific analytics (distinct from general TVL), use the stablecoins API:
bash
undefined如果需要稳定币专属分析(与通用TVL区分),请使用稳定币API:
bash
undefinedStablecoins overview (separate from pro-api)
稳定币概览(与专业版API独立)
Chain-specific stablecoin data
单公链稳定币数据
chain = "Ethereum", "Solana", "BSC", etc.
chain可选值: "Ethereum", "Solana", "BSC", 等.
All chains stablecoin summary
所有公链稳定币汇总
When users ask about "stablecoin net flows" or "stablecoin inflows":
1. Use `stablecoincharts/{chain}` for 30-day stablecoin TVL change (more accurate than general TVL)
2. Or use `/v2/historicalChainTvl/{chain}` as proxy if stablecoin API is unavailable
当用户询问“稳定币净流量”或“稳定币流入”时:
1. 优先使用`stablecoincharts/{chain}`获取30天稳定币TVL变化(比通用TVL更准确)
2. 如果稳定币API不可用,可使用`/v2/historicalChainTvl/{chain}`作为近似指标Yields Pool Data Handling
收益池数据处理
The response is :
/yields/pools{"data": [...], "status": "success"}python
r = session.get(f"https://pro-api.llama.fi/{api_key}/yields/pools")
raw = r.json()
pools = raw.get('data', raw) if isinstance(raw, dict) else raw/yields/pools{"data": [...], "status": "success"}python
r = session.get(f"https://pro-api.llama.fi/{api_key}/yields/pools")
raw = r.json()
pools = raw.get('data', raw) if isinstance(raw, dict) else rawFilter example: TVL > $50M and APY > 0
过滤示例: TVL > $50M 且 APY > 0
filtered = [p for p in pools if p.get('tvlUsd', 0) >= 50_000_000 and (p.get('apy') or 0) > 0]
**Key pool fields**:
| Field | Type | Description |
|-------|------|-------------|
| `pool` | UUID string | Unique pool identifier |
| `chain` | string | Chain name |
| `project` | string | Protocol name |
| `symbol` | string | Token pair (e.g. "USDC-WETH") |
| `tvlUsd` | number | TVL in USD |
| `apy` | number | Current APY % |
| `apyBase` | number | Base APY (lending/trading fees) |
| `apyReward` | number | Incentive APY (token rewards) |
| `ilRisk` | "yes"/"no" | Impermanent loss risk |
| `exposure` | "single"/"multi" | Single vs multi-asset exposure |
| `apyPct7D` | number | APY change past 7 days |filtered = [p for p in pools if p.get('tvlUsd', 0) >= 50_000_000 and (p.get('apy') or 0) > 0]
**核心收益池字段**:
| 字段 | 类型 | 说明 |
|-------|------|-------------|
| `pool` | UUID字符串 | 收益池唯一标识 |
| `chain` | 字符串 | 部署公链名称 |
| `project` | 字符串 | 协议名称 |
| `symbol` | 字符串 | 代币对(例如 "USDC-WETH") |
| `tvlUsd` | 数字 | TVL(美元计价) |
| `apy` | 数字 | 当前APY % |
| `apyBase` | 数字 | 基础APY(借贷/交易手续费产生) |
| `apyReward` | 数字 | 激励APY(代币奖励产生) |
| `ilRisk` | "yes"/"no" | 是否存在无常损失风险 |
| `exposure` | "single"/"multi" | 单资产/多资产敞口 |
| `apyPct7D` | 数字 | 过去7天APY变动 |