Open DeFi data API — TVL by protocol/chain, token prices, stablecoin supply, yield pools, fees and revenue. Free tier requires no API key.
- 01TVL leaderboards
- 02token spot pricing
- 03yield/APY discovery
- 04stablecoin dashboards
- 05protocol fees and revenue
| Variable | Scope | Description |
|---|---|---|
| DEFILLAMA_PRO_API_KEY | Server | Optional Pro API key (only needed for premium endpoints / higher rate limits). Server-side only. |
Hit the open DeFiLlama REST API directly with `fetch` — no SDK, no key required for the free endpoints. Use `https://api.llama.fi/protocols` and `/protocol/{slug}` for TVL, `https://coins.llama.fi/prices/current/{coins}` (e.g. `ethereum:0x...,coingecko:bitcoin`) for spot prices, `https://yields.llama.fi/pools` for yields, and `https://stablecoins.llama.fi/stablecoins` for stablecoin supply. Cache responses for at least 60s in an edge function or Redis since data refreshes hourly server-side. For premium endpoints (`https://pro-api.llama.fi/{API_KEY}/...`) read `DEFILLAMA_PRO_API_KEY` from the server only.
- ⚑Free endpoints have no API key but are not unlimited — abusive traffic gets cloudflare-rate-limited; cache server-side and respect the documented update cadence (~1h for TVL/yields).
- ⚑Coin price keys use the `chain:address` format (e.g. `ethereum:0xA0b8...`) or `coingecko:slug` — wrong namespace silently returns an empty `coins` object.
- ⚑Different domains for different products: `api.llama.fi` (protocols/TVL), `coins.llama.fi` (prices), `yields.llama.fi` (pools), `stablecoins.llama.fi` — don't assume one base URL.
- ⚑Protocol `slug` is not the protocol's display name — fetch `/protocols` once and map names to slugs.
- ⚑TVL excludes double-counted liquid-staking and borrowed positions by default; use `tvl` vs `tvlPrev*` carefully and read the methodology before quoting numbers.