DeFi API

Read-only DeFi analytics endpoints. Backed by DeFiLlama; values reflect the provider’s most recent snapshot.

Base URL

https://api.mangrovedeveloper.ai/api/v1/defi

Authentication

All endpoints require a JWT bearer token.
Authorization: Bearer YOUR_JWT_TOKEN

Endpoints

Get protocol TVL

GET /api/v1/defi/protocol/{protocol}/tvl Total Value Locked for a single DeFi protocol, broken down by chain. Path Parameters:
  • protocol (string, required): Protocol name or slug. Examples: aave, uniswap, lido.
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.mangrovedeveloper.ai/api/v1/defi/protocol/aave/tvl"
Response (200 OK):
{
  "success": true,
  "protocol": "aave",
  "tvl_usd": 12450000000.0,
  "chains": {
    "Ethereum": 8200000000.0,
    "Polygon": 1800000000.0,
    "Arbitrum": 1200000000.0,
    "Avalanche": 850000000.0,
    "Optimism": 400000000.0
  },
  "data": {}
}

Get chain TVL

GET /api/v1/defi/chain/{chain}/tvl Total Value Locked across all protocols on a blockchain, plus the top 10 protocols on that chain. Path Parameters:
  • chain (string, required): Blockchain name. Examples: Ethereum, Solana, Arbitrum, Polygon.
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.mangrovedeveloper.ai/api/v1/defi/chain/Ethereum/tvl"
Response (200 OK):
{
  "success": true,
  "chain": "Ethereum",
  "tvl_usd": 64500000000.0,
  "top_protocols": [
    {"name": "Lido", "tvl": 22100000000.0, "category": "Liquid Staking"},
    {"name": "EigenLayer", "tvl": 11800000000.0, "category": "Restaking"},
    {"name": "Aave", "tvl": 8200000000.0, "category": "Lending"}
  ],
  "data": {}
}

Get stablecoin metrics

GET /api/v1/defi/stablecoins/metrics Total stablecoin supply with per-chain breakdown.
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.mangrovedeveloper.ai/api/v1/defi/stablecoins/metrics"
Response (200 OK):
{
  "success": true,
  "total_supply_usd": 215000000000.0,
  "supply_by_chain": {
    "Ethereum": 125000000000.0,
    "Tron": 58000000000.0,
    "BSC": 8500000000.0,
    "Solana": 5200000000.0,
    "Arbitrum": 4800000000.0
  },
  "data": {}
}

Pro endpoints

These five endpoints expose the paid DeFiLlama Pro tier. They require a Pro, Startup, or Enterprise plan (an unentitled plan returns 403 TIER_UPGRADE_REQUIRED) and share a 1,000 calls/account/month budget (429 quota_exceeded once exhausted). Agents paying per call via x402 are not subscription-gated. Each returns a { "success": true, "count": N, "data": [...] } envelope.
EndpointReturnsSDK method
GET /defi/token-unlockstoken unlock schedules + supply metricsclient.defi.get_token_unlocks()
GET /defi/perp-fundingaggregated perpetual funding ratesclient.defi.get_perp_funding()
GET /defi/treasuriesprotocol treasury holdingsclient.defi.get_treasuries()
GET /defi/etf-flowscrypto ETF net flowsclient.defi.get_etf_flows()
GET /defi/lending-rateslending / borrow ratesclient.defi.get_lending_borrow_rates()
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.mangrovedeveloper.ai/api/v1/defi/token-unlocks"
The SDK ships a runnable quickstart for all five at examples/defi_pro.py (with 403/429 handling).

Error Codes

CodeHTTP StatusDescription
AUTH_REQUIRED401Missing or invalid bearer token
TIER_UPGRADE_REQUIRED403Pro endpoint requested on a plan without defi_pro (Pro/Startup/Enterprise required)
RESOURCE_NOT_FOUND404Unknown protocol or chain slug
quota_exceeded429Monthly DeFiLlama Pro cap reached (1,000 calls/account/month)
INTERNAL_ERROR500Upstream provider (DeFiLlama) error