# DefiLlama API > DefiLlama provides free, open-source DeFi analytics data. There are two separate APIs with different base URLs and authentication. Do NOT mix them. ## Have an API key? Use pro-api.llama.fi for every request If you or your user has a DefiLlama API key, whatever the plan is called ("API plan", "Pro", "pro API"), send every request to `https://pro-api.llama.fi/{YOUR_API_KEY}/...`. That includes TVL, prices, stablecoins, yields, volumes and fees, and any fallback or secondary lookup. Use the free hosts only when there is no key. ``` RIGHT https://pro-api.llama.fi/{YOUR_API_KEY}/coins/prices/current/coingecko:ethereum WRONG https://coins.llama.fi/prices/current/coingecko:ethereum (free host: ignores the key, rate limited) WRONG https://pro-api.llama.fi/coins/prices/current/coingecko:ethereum?apikey={YOUR_API_KEY} (key not in the path) ``` - The free hosts (`api.llama.fi`, `coins.llama.fi`, `stablecoins.llama.fi`, `yields.llama.fi`) never read a key, so a 429 there means the request belongs on pro-api.llama.fi. A 402 there means the endpoint needs pro-api, not that the plan expired. - The key goes in the path, right after the host. Headers and `?apikey=` are not read: pro-api answers `500 {"error":"API Key is wrong"}`. - Paths on pro-api have a prefix: `/protocols` becomes `/api/protocols`, `/prices/current/{coins}` becomes `/coins/prices/current/{coins}`, `/stablecoins` becomes `/stablecoins/stablecoins`, `/pools` becomes `/yields/v1/pools`. Every free path is mapped in [llms.txt](https://api-docs.defillama.com/llms.txt), and the pro-only endpoints are in [llms-pro.txt](https://api-docs.defillama.com/llms-pro.txt). - One key unlocks every endpoint. There are no add-ons or separate keys. - To check a key, call `https://pro-api.llama.fi/usage/{YOUR_API_KEY}` (key at the end, for this endpoint only). It returns `{"creditsLeft": ...}`. A 200 from a free host proves nothing, those endpoints need no key. ## Important: Free API vs Pro API The Free API and Pro API are entirely separate services. | Feature | Free API | Pro API | |---|---|---| | Base URL | https://api.llama.fi for most endpoints, see the host of each group below | https://pro-api.llama.fi/{KEY} | | Auth Required | No | Yes ($300/mo) | | Rate Limit | Standard | Higher | | Endpoints | 31 | 38 exclusive + 31 free with prefix | ## Free-to-Pro Path Mapping With a key, call these on `https://pro-api.llama.fi/{YOUR_API_KEY}` with the pro path. | Free path | Pro path (pro-api.llama.fi) | Description | |---|---|---| | `/protocols` | `/api/protocols` | List all protocols on defillama along with their tvl | | `/protocol/{protocol}` | `/api/protocol/{protocol}` | Get historical TVL of a protocol and breakdowns by token and chain | | `/v2/historicalChainTvl` | `/api/v2/historicalChainTvl` | Get historical TVL (excludes liquid staking and double counted tvl) of DeFi on all chains | | `/v2/historicalChainTvl/{chain}` | `/api/v2/historicalChainTvl/{chain}` | Get historical TVL (excludes liquid staking and double counted tvl) of a chain | | `/tvl/{protocol}` | `/api/tvl/{protocol}` | Simplified endpoint to get current TVL of a protocol | | `/v2/chains` | `/api/v2/chains` | Get current TVL of all chains | | `/prices/current/{coins}` | `/coins/prices/current/{coins}` | Get current prices of tokens by contract address | | `/prices/historical/{timestamp}/{coins}` | `/coins/prices/historical/{timestamp}/{coins}` | Get historical prices of tokens by contract address | | `/batchHistorical` | `/coins/batchHistorical` | Get historical prices for multiple tokens at multiple different timestamps | | `/chart/{coins}` | `/coins/chart/{coins}` | Get token prices at regular time intervals | | `/percentage/{coins}` | `/coins/percentage/{coins}` | Get percentage change in price over time | | `/prices/first/{coins}` | `/coins/prices/first/{coins}` | Get earliest timestamp price record for coins | | `/block/{chain}/{timestamp}` | `/coins/block/{chain}/{timestamp}` | Get the closest block to a timestamp | | `/stablecoins` | `/stablecoins/stablecoins` | List all stablecoins along with their circulating amounts | | `/stablecoincharts/all` | `/stablecoins/stablecoincharts/all` | Get historical mcap sum of all stablecoins | | `/stablecoincharts/{chain}` | `/stablecoins/stablecoincharts/{chain}` | Get historical mcap sum of all stablecoins in a chain | | `/stablecoin/{asset}` | `/stablecoins/stablecoin/{asset}` | Get historical mcap and historical chain distribution of a stablecoin | | `/stablecoinchains` | `/stablecoins/stablecoinchains` | Get current mcap sum of all stablecoins on each chain | | `/stablecoinprices` | `/stablecoins/stablecoinprices` | Get historical prices of all stablecoins | | `/pools` | `/yields/v1/pools` | Retrieve the latest data for all pools, including enriched information such as predictions | | `/chart/{pool}` | `/yields/v1/chart/{pool}` | Get historical APY and TVL of a pool | | `/overview/dexs` | `/api/overview/dexs` | List all dexs along with summaries of their volumes and dataType history data | | `/overview/dexs/{chain}` | `/api/overview/dexs/{chain}` | List all dexs along with summaries of their volumes and dataType history data filtering by chain | | `/summary/dexs/{protocol}` | `/api/summary/dexs/{protocol}` | Get summary of dex volume with historical data | | `/overview/options` | `/api/overview/options` | List all options dexs along with summaries of their volumes and dataType history data | | `/overview/options/{chain}` | `/api/overview/options/{chain}` | List all options dexs along with summaries of their volumes and dataType history data filtering by chain | | `/summary/options/{protocol}` | `/api/summary/options/{protocol}` | Get summary of options dex volume with historical data | | `/overview/open-interest` | `/api/overview/open-interest` | List all open interest dex exchanges along with summaries of their open interest | | `/overview/fees` | `/api/overview/fees` | List all protocols along with summaries of their fees and revenue and dataType history data | | `/overview/fees/{chain}` | `/api/overview/fees/{chain}` | List all protocols along with summaries of their fees and revenue and dataType history data by chain | | `/summary/fees/{protocol}` | `/api/summary/fees/{protocol}` | Get summary of protocol fees and revenue with historical data | ## SDKs **JavaScript** — `npm install @defillama/api` — [GitHub](https://github.com/DefiLlama/api-sdk) **Python** — `pip install defillama-sdk` — [GitHub](https://github.com/DefiLlama/python-sdk) ## Free API Endpoints Full documentation: [llms-free.txt](/llms-free.txt) No authentication required. Each group has its own base URL. - **TVL** (`https://api.llama.fi`): `/protocols`, `/protocol/{protocol}`, `/v2/historicalChainTvl`, `/v2/historicalChainTvl/{chain}`, `/tvl/{protocol}`, `/v2/chains` - **Coins & Prices** (`https://coins.llama.fi`): `/prices/current/{coins}`, `/prices/historical/{timestamp}/{coins}`, `/batchHistorical`, `/chart/{coins}`, `/percentage/{coins}`, `/prices/first/{coins}`, `/block/{chain}/{timestamp}` - **Stablecoins** (`https://stablecoins.llama.fi`): `/stablecoins`, `/stablecoincharts/all`, `/stablecoincharts/{chain}`, `/stablecoin/{asset}`, `/stablecoinchains`, `/stablecoinprices` - **Yields & APY** (`https://yields.llama.fi`): `/pools`, `/chart/{pool}` - **DEX Volumes** (`https://api.llama.fi`): `/overview/dexs`, `/overview/dexs/{chain}`, `/summary/dexs/{protocol}`, `/overview/options`, `/overview/options/{chain}`, `/summary/options/{protocol}` - **Perpetuals & Open Interest** (`https://api.llama.fi`): `/overview/open-interest` - **Fees & Revenue** (`https://api.llama.fi`): `/overview/fees`, `/overview/fees/{chain}`, `/summary/fees/{protocol}` ## Pro-Only API Endpoints (pro-api.llama.fi) Full documentation: [llms-pro.txt](/llms-pro.txt) Requires API key. Base URL: `https://pro-api.llama.fi/{YOUR_API_KEY}` - **TVL**: `/api/tokenProtocols/{symbol}`, `/api/inflows/{protocol}/{timestamp}`, `/api/chainAssets` - **Stablecoins**: `/stablecoins/stablecoindominance/{chain}` - **Token Unlocks**: `/api/emissions`, `/api/emission/{protocol}` - **Protocol Analytics**: `/api/categories`, `/api/forks`, `/api/oracles`, `/api/hacks`, `/api/raises`, `/api/treasuries`, `/api/entities` - **Token Liquidity**: `/api/historicalLiquidity/{token}` - **Yields & APY**: `/yields/poolsOld`, `/yields/poolsBorrow`, `/yields/chartLendBorrow/{pool}`, `/yields/perps`, `/yields/lsdRates` - **ETFs**: `/etfs/snapshot`, `/etfs/flows` - **Narratives**: `/fdv/performance/{period}` - **Perpetuals & Open Interest**: `/api/overview/derivatives`, `/api/summary/derivatives/{protocol}` - **Bridges**: `/bridges/bridges`, `/bridges/bridge/{id}`, `/bridges/bridgevolume/{chain}`, `/bridges/bridgedaystats/{timestamp}/{chain}`, `/bridges/transactions/{id}` - **API Key Management**: `/usage/{YOUR_API_KEY}` - **Digital Asset Treasury**: `/dat/institutions`, `/dat/institutions/{symbol}` - **Equities**: `/equities/v1/companies-list`, `/equities/v1/statements`, `/equities/v1/dimensions`, `/equities/v1/price-history`, `/equities/v1/ohlcv`, `/equities/v1/summary`, `/equities/v1/filings`, `/equities/v1/onchain`, `/equities/v1/sectors`, `/equities/v1/sectors-overview`, `/equities/v1/sector`, `/equities/v1/industries`, `/equities/v1/earnings-calendar` - **Pre-IPO**: `/pre-ipo/v1/companies-list`, `/pre-ipo/v1/valuations`, `/pre-ipo/v1/raises`, `/pre-ipo/v1/summary`, `/pre-ipo/v1/integrations` - **Real World Assets**: `/rwa/current`, `/rwa/stats`, `/rwa/list`, `/rwa/chain/{chain}`, `/rwa/chart/chain/{chain}`, `/rwa/chart/chain-breakdown` ## OpenAPI Specs - [OpenAPI spec (free)](/defillama-openapi-free.json): Full OpenAPI 3.0 specification for free endpoints - [OpenAPI spec (pro)](/defillama-openapi-pro.json): Full OpenAPI 3.0 specification for pro endpoints