Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions defillama-openapi-free.json

Large diffs are not rendered by default.

27,249 changes: 13,634 additions & 13,615 deletions defillama-openapi-pro.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions examples/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@
<h1>DefiLlama API documentation</h1>
<p>Explore free and Pro API endpoints for DeFi data.</p>
<p>
<a href="/llms-free.txt">Free API endpoints</a> ·
<a href="/llms-pro.txt">Pro API endpoints</a>
<strong>Have an API key?</strong> Send every request to
<code>https://pro-api.llama.fi/YOUR_API_KEY/…</code>, including
prices, TVL, stablecoins and yields. The free hosts (api.llama.fi,
coins.llama.fi, stablecoins.llama.fi, yields.llama.fi) never read a
key and are rate limited.
</p>
<p>
<a href="/llms.txt">Overview for AI agents</a> ·
<a href="/llms-pro.txt">API endpoints with a key</a> ·
<a href="/llms-free.txt">Free API endpoints (no key)</a>
</p>
</main>
</div>
Expand Down
5 changes: 3 additions & 2 deletions examples/web/src/components/ApiKeyInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const switchToFreeApi = () => {
<div class="api-key-input">
<div class="header">
<div class="title-section">
<h3>DefiLlama Pro API Key</h3>
<h3>DefiLlama API Key (API plan)</h3>
<div class="header-actions">
<button
v-if="isProUser"
Expand Down Expand Up @@ -122,7 +122,8 @@ const switchToFreeApi = () => {
Your API key will be injected into requests to
<b><code>https://pro-api.llama.fi</code></b> endpoints.
<br />
When your API key is set, free endpoints will be changed to pro version to bypass rate limits"
When your API key is set, free endpoints switch to their pro-api.llama.fi
versions and use the API plan’s higher rate limits.
</p>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions examples/web/src/pages/StandaloneApiReferencePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const currentBaseUrl = ref<string>('https://api.llama.fi')
const configuration = ref(
apiReferenceConfigurationSchema.parse({
isEditable: false,
/**
* Without this, Scalar opens on the first custom code sample (the JavaScript SDK). curl shows the
* full URL, so readers and agents see exactly which host and key placement to use.
*/
defaultHttpClient: { targetKey: 'shell', clientKey: 'curl' },
// Add path routing option
...(window.location.pathname.startsWith('/path-routing')
? {
Expand Down
58 changes: 54 additions & 4 deletions llms-free.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
# DefiLlama Free API
# DefiLlama Free API (no API key)

> Free API — no authentication required. Endpoints are served from several hosts, use the base URL listed on each endpoint.
> Free API, for users with no API key. Each endpoint lists its free base URL and, under it, the URL to use with a key.

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

**Base URL for endpoints below:** `https://api.llama.fi` (unless an endpoint lists its own)

## TVL

### GET /protocols
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/protocols`
List all protocols on defillama along with their tvl
Returns: array of {id, name, symbol, category, chains, tvl, chainTvls, change_1d, change_7d}

### GET /protocol/{protocol}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/protocol/{protocol}`
Get historical TVL of a protocol and breakdowns by token and chain

**Parameters:**
Expand All @@ -21,11 +39,13 @@ Returns: {id, name, symbol, category, chains, currentChainTvls, chainTvls}

### GET /v2/historicalChainTvl
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/v2/historicalChainTvl`
Get historical TVL (excludes liquid staking and double counted tvl) of DeFi on all chains
Returns: array of {date, tvl}

### GET /v2/historicalChainTvl/{chain}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/v2/historicalChainTvl/{chain}`
Get historical TVL (excludes liquid staking and double counted tvl) of a chain

**Parameters:**
Expand All @@ -34,6 +54,7 @@ Returns: array of {date, tvl}

### GET /tvl/{protocol}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/tvl/{protocol}`
Simplified endpoint to get current TVL of a protocol

**Parameters:**
Expand All @@ -42,6 +63,7 @@ Returns: number

### GET /v2/chains
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/v2/chains`
Get current TVL of all chains
Returns: array of {gecko_id, tvl, tokenSymbol, cmcId, name, chainId}

Expand All @@ -51,6 +73,7 @@ Returns: array of {gecko_id, tvl, tokenSymbol, cmcId, name, chainId}

### GET /prices/current/{coins}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/prices/current/{coins}`
Get current prices of tokens by contract address

**Parameters:**
Expand All @@ -59,6 +82,7 @@ Returns: {coins}

### GET /prices/historical/{timestamp}/{coins}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/prices/historical/{timestamp}/{coins}`
Get historical prices of tokens by contract address

**Parameters:**
Expand All @@ -68,6 +92,7 @@ Returns: {coins}

### GET /batchHistorical
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/batchHistorical`
Get historical prices for multiple tokens at multiple different timestamps

**Parameters:**
Expand All @@ -77,6 +102,7 @@ Returns: {coins}

### GET /chart/{coins}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/chart/{coins}`
Get token prices at regular time intervals

**Parameters:**
Expand All @@ -89,6 +115,7 @@ Returns: {coins}

### GET /percentage/{coins}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/percentage/{coins}`
Get percentage change in price over time

**Parameters:**
Expand All @@ -100,6 +127,7 @@ Returns: {coins}

### GET /prices/first/{coins}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/prices/first/{coins}`
Get earliest timestamp price record for coins

**Parameters:**
Expand All @@ -108,6 +136,7 @@ Returns: {coins}

### GET /block/{chain}/{timestamp}
**Base URL:** `https://coins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/coins/block/{chain}/{timestamp}`
Get the closest block to a timestamp

**Parameters:**
Expand All @@ -121,14 +150,17 @@ Returns: {height, timestamp}

### GET /stablecoins
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoins`
List all stablecoins along with their circulating amounts

**Parameters:**
- `includePrices` (query, boolean, optional) — set whether to include current stablecoin prices Example: `true`
Returns: {peggedAssets}
**Response:** `peggedAssets[]`. Each asset's supply is nested in `circulating` under its `pegType`: `circulating.peggedUSD` for USD-pegged coins, `circulating.peggedEUR` for EURC, and so on. Read `circulating[asset.pegType]`. `price` is the USD price of one coin, or `null` when there is no quote (many assets). Compute the USD value as `circulating[asset.pegType] * price` only when `price` is a number. Otherwise the USD value is unavailable, not zero.

### GET /stablecoincharts/all
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoincharts/all`
Get historical mcap sum of all stablecoins

**Parameters:**
Expand All @@ -137,6 +169,7 @@ Returns: array of {date, totalCirculating}

### GET /stablecoincharts/{chain}
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoincharts/{chain}`
Get historical mcap sum of all stablecoins in a chain

**Parameters:**
Expand All @@ -146,6 +179,7 @@ Returns: array of {date, totalCirculating}

### GET /stablecoin/{asset}
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoin/{asset}`
Get historical mcap and historical chain distribution of a stablecoin

**Parameters:**
Expand All @@ -154,11 +188,13 @@ Returns: {id, name, symbol, totalCirculating, chainCirculating}

### GET /stablecoinchains
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoinchains`
Get current mcap sum of all stablecoins on each chain
Returns: array of {name, totalCirculating}
Returns: array of {name, totalCirculatingUSD}

### GET /stablecoinprices
**Base URL:** `https://stablecoins.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/stablecoins/stablecoinprices`
Get historical prices of all stablecoins
Returns: array of {date, prices}

Expand All @@ -168,11 +204,13 @@ Returns: array of {date, prices}

### GET /pools
**Base URL:** `https://yields.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/yields/v1/pools`
Retrieve the latest data for all pools, including enriched information such as predictions
Returns: {status, data}

### GET /chart/{pool}
**Base URL:** `https://yields.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/yields/v1/chart/{pool}`
Get historical APY and TVL of a pool

**Parameters:**
Expand All @@ -185,6 +223,7 @@ Returns: {status, data}

### GET /overview/dexs
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/dexs`
List all dexs along with summaries of their volumes and dataType history data

**Parameters:**
Expand All @@ -194,6 +233,7 @@ Returns: {protocols, totalDataChart, allChains}

### GET /overview/dexs/{chain}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/dexs/{chain}`
List all dexs along with summaries of their volumes and dataType history data filtering by chain

**Parameters:**
Expand All @@ -204,6 +244,7 @@ Returns: {protocols, totalDataChart}

### GET /summary/dexs/{protocol}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/summary/dexs/{protocol}`
Get summary of dex volume with historical data

**Parameters:**
Expand All @@ -214,6 +255,7 @@ Returns: {name, total24h, totalAllTime, totalDataChart, totalDataChartBreakdown,

### GET /overview/options
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/options`
List all options dexs along with summaries of their volumes and dataType history data

**Parameters:**
Expand All @@ -224,28 +266,33 @@ Returns: {protocols, totalDataChart}

### GET /overview/options/{chain}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/options/{chain}`
List all options dexs along with summaries of their volumes and dataType history data filtering by chain

**Parameters:**
- `chain` (path, string, required) — chain name, list of all supported chains can be found under allChains attribute in /overview/options response Example: `ethereum`
- `excludeTotalDataChart` (query, boolean, required) — true to exclude aggregated chart from response Example: `true`
- `excludeTotalDataChartBreakdown` (query, boolean, required) — true to exclude broken down chart from response Example: `true`
- `dataType` (query, string, optional) — Desired data type, dailyNotionalVolume by default. (one of: dailyPremiumVolume, dailyNotionalVolume) Example: `dailyPremiumVolume`
Returns: {totalDataChart, totalDataChartBreakdown, breakdown24h, breakdown30d, chain, allChains, total24h, total48hto24h, total7d, total14dto7d, total60dto30d, total30d, total1y, change_1d, change_7d, change_1m, change_7dover7d, change_30dover30d, total7DaysAgo, total30DaysAgo, totalAllTime, protocols}

### GET /summary/options/{protocol}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/summary/options/{protocol}`
Get summary of options dex volume with historical data

**Parameters:**
- `protocol` (path, string, required) — protocol slug Example: `derive`
- `dataType` (query, string, optional) — Desired data type, dailyNotionalVolume by default. (one of: dailyPremiumVolume, dailyNotionalVolume) Example: `dailyPremiumVolume`
Returns: {id, name, url, description, logo, gecko_id, cmcId, chains, twitter, governanceID, github, treasury, symbol, address, childProtocols, linkedProtocols, defillamaId, disabled, displayName, module, category, methodologyURL, methodology, forkedFrom, audits, audit_links, versionKey, parentProtocol, previousNames, slug, protocolType, total24h, total48hto24h, total7d, totalAllTime, totalDataChart, totalDataChartBreakdown, change_1d}

---

## Perpetuals & Open Interest

### GET /overview/open-interest
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/open-interest`
List all open interest dex exchanges along with summaries of their open interest

**Parameters:**
Expand All @@ -259,6 +306,7 @@ Returns: {protocols, totalDataChart, allChains}

### GET /overview/fees
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/fees`
List all protocols along with summaries of their fees and revenue and dataType history data

**Parameters:**
Expand All @@ -269,6 +317,7 @@ Returns: {protocols, totalDataChart, totalDataChartBreakdown}

### GET /overview/fees/{chain}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/overview/fees/{chain}`
List all protocols along with summaries of their fees and revenue and dataType history data by chain

**Parameters:**
Expand All @@ -280,9 +329,10 @@ Returns: {protocols, totalDataChart, totalDataChartBreakdown}

### GET /summary/fees/{protocol}
**Base URL:** `https://api.llama.fi`
**With an API key:** `https://pro-api.llama.fi/{YOUR_API_KEY}/api/summary/fees/{protocol}`
Get summary of protocol fees and revenue with historical data

**Parameters:**
- `protocol` (path, string, required) — protocol slug Example: `derive`
- `dataType` (query, string, optional) — Desired data type, dailyFees by default. (one of: dailyFees, dailyRevenue, dailyHoldersRevenue) Example: `dailyFees`
Returns: {id, name, url, referralUrl, description, logo, gecko_id, cmcId, chains, twitter, github, symbol, address, childProtocols, linkedProtocols, defillamaId, disabled, displayName, module, category, methodologyURL, methodology, forkedFrom, audits, audit_links, versionKey, governanceID, treasury, parentProtocol, previousNames, latestFetchIsOk, slug, protocolType, total24h, total48hto24h, total7d, totalAllTime, change_1d, totalDataChart, totalDataChartBreakdown}
Returns: {id, name, url, referralUrl, description, logo, gecko_id, cmcId, chains, twitter, github, symbol, address, childProtocols, linkedProtocols, defillamaId, disabled, displayName, module, category, methodologyURL, methodology, forkedFrom, audits, audit_links, versionKey, governanceID, treasury, parentProtocol, previousNames, slug, protocolType, total24h, total48hto24h, total7d, totalAllTime, change_1d, totalDataChart, totalDataChartBreakdown}
Loading
Loading