mcpField
D
defillama-api

defillama-api

github.com/agiprolabsデータ・データベース456451 回インストール8 週間前に更新
リポジトリ

defillama-api について

defillama-apiは、DeFiLlama APIを使ったDeFiデータ分析のリファレンススキルです。TVL、トークン価格、DEX取引量、手数料、ステーブルコイン、ブリッジ一覧のエンドポイントと利用例を扱います。

主な機能

  1. 01プロトコルのTVLと履歴データ
  2. 02現在・過去のトークン価格
  3. 03DEX取引量と手数料の概要
  4. 04ステーブルコイン供給データ
  5. 05ブリッジ一覧

活用シーン

  1. 01チェーン間でプロトコルTVLを比較
  2. 02複数トークンの価格を取得
  3. 03チェーン別のDeFi活動を確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/agiprolabs/claude-trading-skills --skill defillama-api

インストール後、Claude Code で/defillama-apiを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
coin_identifiers.md
endpoints.md
error_handling.md
scripts/
defi_snapshot.py
price_lookup.py

詳細

DeFiLlama API — DeFi マクロ分析

DeFiLlama は、DeFi の TVL アグリゲーターとして最大規模です。ほとんどのエンドポイントは認証不要で無料で、すべてのチェーンを対象に、TVL、トークン価格、DEX 取引量、手数料/収益、ステーブルコイン、ブリッジをカバーしています。

クイックスタート

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"]

ベース URL

サービスベース URL認証
TVL/プロトコルhttps://api.llama.fi無料
コイン価格https://coins.llama.fi無料
ステーブルコインhttps://stablecoins.llama.fi無料
イールドhttps://yields.llama.fiPro($300/mo)
ブリッジhttps://bridges.llama.fi無料(一覧)/Pro(詳細)
Pro APIhttps://pro-api.llama.fi/{KEY}/api/...URL パスに Pro キー

レート制限:無料では 5 分あたり約 500 リクエストです。Pro では 1 分あたり 1,000 リクエスト、月あたり 100 万回の呼び出しです。

TVL とプロトコルデータ

# 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)

トークン価格

コイン識別子には {chain}:{address} 形式を使用します。

  • solana:So11111111111111111111111111111111111111112(SOL)
  • ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7(USDT)
  • coingecko:bitcoin(チェーンを指定しない検索)
# 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}
複数の過去価格を一括取得
# POST for multiple timestamps per coin
POST /batchHistorical
Body: {"coins": {"solana:So11...": [1709251200, 1709337600]}}

DEX 取引量

# 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, ...}

手数料と収益

# 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[], ...}

ステーブルコイン

# 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/stablecoinprices

ブリッジ

# List all bridges
GET https://bridges.llama.fi/bridges
# Optional: includeChains=true
# Returns: {bridges: [{name, volume stats, chains, ...}]}

よくあるパターン

プロトコルの TVL 比較
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)
複数トークンの価格検索
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 の概要
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),
    }
過去価格の分析
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:So11...')
        date_str: Date string 'YYYY-MM-DD'
    """
    from datetime import datetime, timezone
    dt = datetime.strptime(date_str, "%Y-%m-%d").replace(tzinfo=timezone.utc)
    ts = int(dt.timestamp())
    resp = httpx.get(f"https://coins.llama.fi/prices/historical/{ts}/{coin}")
    data = resp.json().get("coins", {})
    return data.get(coin, {}).get("price", 0)

無料エンドポイントと Pro エンドポイント

カテゴリー無料Pro($300/mo)
TVL/プロトコルはいはい
コイン価格はいはい
DEX 取引量(概要)はいはい
手数料/収益(概要)はいはい
ステーブルコインはいはい
ブリッジ(一覧)はいはい
イールド/プールいいえはい
ブリッジの詳細いいえはい
デリバティブいいえはい
排出量/アンロックいいえはい
トレジャリーいいえはい
ハッキングデータベースいいえはい

DeFiLlama と代替サービスの使い分け

必要なこと使用するサービス
プロトコルの TVL 比較DeFiLlama
マルチチェーンのトークン価格DeFiLlama(無料の一括取得)
特定のタイムスタンプにおける過去価格DeFiLlama
DeFi のマクロ分析DeFiLlama
Solana トークンの OHLCVBirdeye または SolanaTracker
リアルタイムのトークンデータDexScreener または Birdeye
ウォレットの損益SolanaTracker
オンチェーンのトランザクションデータHelius

ファイル

リファレンス
  • references/endpoints.md — パラメーターとレスポンススキーマを含む、すべてのエンドポイント一覧
  • references/coin_identifiers.md — チェーンプレフィックス、アドレス形式、一括検索のパターン
  • references/error_handling.md — レート制限、エラーコード、再試行方法、大きなレスポンスの処理
スクリプト
  • scripts/defi_snapshot.py — Solana DeFi の概要:TVL、取引量、手数料、主要プロトコル
  • scripts/price_lookup.py — 過去との比較を含む、複数トークンの価格検索

コメント