Skip to content
Open
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
1,032 changes: 1,032 additions & 0 deletions defillama-openapi-pro.json

Large diffs are not rendered by default.

153 changes: 152 additions & 1 deletion llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DefiLlama API – Complete LLM Integration Guide
## Overview

This document provides comprehensive guidance for LLMs to interact with ALL DefiLlama APIs.
Includes API-Plan-only endpoints (marked with 🔒) and free endpoints, with full parameters and responses.
Includes API-Plan-only endpoints (marked with 🔒), beta endpoints (marked with 🧪), and free endpoints, with full parameters and responses.

## Base URLs

Expand Down Expand Up @@ -179,6 +179,157 @@ SECTION 1: TVL & PROTOCOL DATA
}]
```

## Protocol TVL Charts (v2)

These endpoints provide time-series chart data for individual protocol TVL.
The `key` parameter selects which metric to return. The `currency` parameter
(token-breakdown only) switches values from USD to raw token amounts.

8a. 🔒 🧪 **GET /api/v2/metrics/tvl/protocol/{protocol}**
Base: `https://pro-api.llama.fi`
Purpose: Aggregate TVL metrics for a protocol (metadata + current TVL figures)
Parameters:
- protocol (path, required): Protocol slug (e.g., "aave")
Response:
```json
{
"id": "parent#aave",
"name": "Aave",
"symbol": "AAVE",
"url": "https://aave.com",
"description": "Decentralized lending protocol",
"chain": "Multi-Chain",
"logo": "https://icons.llama.fi/aave.png",
"category": "Lending",
"chains": ["Ethereum", "Polygon", "Avalanche"],
"currentChainTvls": {"Ethereum": 3200000000, "Polygon": 1500000000},
"mcap": 2400000000,
"twitter": "AaveAave",
"forkedFrom": [],
"openSource": true
}
```

8b. 🔒 🧪 **GET /api/v2/chart/tvl/protocol/{protocol}**
Base: `https://pro-api.llama.fi`
Purpose: Historical TVL value chart for a protocol
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Metric to return. Omit for default TVL. Options: "all" (sum of tvl+borrowed+staking+pool2+vesting), "staking", "borrowed", "vesting", "pool2"
Response: Array of [timestamp, value] pairs
```json
[[1609459200, 5200000000], [1609545600, 5250000000]]
```
Examples:
- `/v2/chart/tvl/protocol/uniswap` — default TVL
- `/v2/chart/tvl/protocol/uniswap?key=all` — sum of all metrics
- `/v2/chart/tvl/protocol/morpho?key=borrowed` — borrowed only

8c. 🔒 🧪 **GET /api/v2/chart/tvl/protocol/{protocol}/chain-breakdown**
Base: `https://pro-api.llama.fi`
Purpose: Historical TVL chart broken down by chain
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Metric to return. Same options as 8b.
Response: Array of [timestamp, {chain: value}] pairs
```json
[[1609459200, {"Ethereum": 3200000000, "Polygon": 1500000000}]]
```
Examples:
- `/v2/chart/tvl/protocol/euler/chain-breakdown` — default TVL per chain
- `/v2/chart/tvl/protocol/euler/chain-breakdown?key=borrowed` — borrowed per chain

8d. 🔒 🧪 **GET /api/v2/chart/tvl/protocol/{protocol}/token-breakdown**
Base: `https://pro-api.llama.fi`
Purpose: Historical TVL chart broken down by token
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Metric to return. Same options as 8b.
- currency (query, optional): Set to "tokens" to return raw token amounts instead of USD
Response: Array of [timestamp, {token: value}] pairs
```json
[[1609459200, {"USDC": 1000000000, "USDT": 800000000, "WETH": 500000000}]]
```
Examples:
- `/v2/chart/tvl/protocol/aave/token-breakdown` — value in USD
- `/v2/chart/tvl/protocol/aave/token-breakdown?currency=tokens` — value in raw token amounts

## Protocol Treasury Charts (v2)

These endpoints provide time-series chart data for protocol treasuries.
By default, the protocol's own tokens (OwnTokens) are excluded. Use the
`key` parameter to filter: "OwnTokens" for own tokens only, "all" to include everything.

8e. 🔒 🧪 **GET /api/v2/metrics/treasury/protocol/{protocol}**
Base: `https://pro-api.llama.fi`
Purpose: Aggregate treasury metrics for a protocol (metadata + current treasury figures)
Parameters:
- protocol (path, required): Protocol slug (e.g., "aave")
Response:
```json
{
"id": "parent#aave",
"name": "Aave",
"symbol": "AAVE",
"url": "https://aave.com",
"description": "Decentralized lending protocol",
"chain": "Multi-Chain",
"logo": "https://icons.llama.fi/aave.png",
"category": "Lending",
"chains": ["Ethereum", "Polygon", "Avalanche"],
"currentChainTvls": {"Ethereum": 80000000, "Polygon": 20000000},
"mcap": 2400000000,
"twitter": "AaveAave"
}
```

8f. 🔒 🧪 **GET /api/v2/chart/treasury/protocol/{protocol}**
Base: `https://pro-api.llama.fi`
Purpose: Historical treasury value chart for a protocol (excludes OwnTokens by default)
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Token filter. Omit to exclude OwnTokens. "OwnTokens" for own tokens only. "all" for sum including OwnTokens.
Response: Array of [timestamp, value] pairs
```json
[[1609459200, 120000000], [1609545600, 121000000]]
```
Examples:
- `/v2/chart/treasury/protocol/uniswap` — excludes OwnTokens
- `/v2/chart/treasury/protocol/uniswap?key=OwnTokens` — own tokens only
- `/v2/chart/treasury/protocol/uniswap?key=all` — sum of all including OwnTokens

8g. 🔒 🧪 **GET /api/v2/chart/treasury/protocol/{protocol}/chain-breakdown**
Base: `https://pro-api.llama.fi`
Purpose: Historical treasury chart broken down by chain (excludes OwnTokens by default)
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Token filter. Same options as 8f.
Response: Array of [timestamp, {chain: value}] pairs
```json
[[1609459200, {"Ethereum": 80000000, "Polygon": 20000000}]]
```
Examples:
- `/v2/chart/treasury/protocol/aave/chain-breakdown` — excludes OwnTokens
- `/v2/chart/treasury/protocol/aave/chain-breakdown?key=OwnTokens` — own tokens only per chain
- `/v2/chart/treasury/protocol/aave/chain-breakdown?key=all` — all tokens per chain

8h. 🔒 🧪 **GET /api/v2/chart/treasury/protocol/{protocol}/token-breakdown**
Base: `https://pro-api.llama.fi`
Purpose: Historical treasury chart broken down by token
Parameters:
- protocol (path, required): Protocol slug
- key (query, optional): Token filter. Same options as 8f.
- currency (query, optional): Set to "tokens" to return raw token amounts instead of USD
Response: Array of [timestamp, {token: value}] pairs
```json
[[1609459200, {"AAVE": 50000000, "USDC": 30000000, "WETH": 20000000}]]
```
Examples:
- `/v2/chart/treasury/protocol/aave/token-breakdown` — value in USD, excludes OwnTokens
- `/v2/chart/treasury/protocol/aave/token-breakdown?currency=tokens` — raw token amounts
- `/v2/chart/treasury/protocol/aave/token-breakdown?key=OwnTokens&currency=tokens` — own tokens in raw amounts
- `/v2/chart/treasury/protocol/aave/token-breakdown?key=all` — all tokens in USD

9. 🔒 **GET /api/chainAssets**
Base: `https://pro-api.llama.fi`
Purpose: Asset breakdown across all chains
Expand Down
33 changes: 33 additions & 0 deletions packages/api-reference/src/components/BetaBadge/BetaBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<Badge
v-if="showBetaBadge"
class="api-beta-badge">
Beta
</Badge>
</template>

<script setup lang="ts">
import { computed } from 'vue'

import { Badge } from '@/components/Badge'

const { operation } = defineProps<{
operation?: {
'x-api-beta'?: boolean
[key: string]: any
}
}>()

const showBetaBadge = computed(() => {
return operation?.['x-api-beta'] === true
})
</script>

<style scoped>
.api-beta-badge {
font-weight: var(--scalar-bold);
font-size: var(--scalar-micro);
color: #9333ea;
margin-left: 8px;
}
</style>
1 change: 1 addition & 0 deletions packages/api-reference/src/components/BetaBadge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as BetaBadge } from './BetaBadge.vue'
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ const title = computed(
class="pro-indicator">
API Plan
</span>
<span
v-if="transformedOperation.information?.['x-api-beta'] === true"
class="beta-indicator">
Beta
</span>
</span>
</a>
</li>
Expand Down Expand Up @@ -127,4 +132,15 @@ const title = computed(
border-radius: 6px;
display: inline-block;
}

.beta-indicator {
margin-left: 8px;
color: #9333ea;
font-size: var(--scalar-micro);
font-weight: var(--scalar-bold);
background: color-mix(in srgb, #9333ea, transparent 90%);
padding: 1px 4px;
border-radius: 6px;
display: inline-block;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Anchor } from '@/components/Anchor'
import { Badge } from '@/components/Badge'
import { HttpMethod } from '@/components/HttpMethod'
import OperationPath from '@/components/OperationPath.vue'
import { BetaBadge } from '@/components/BetaBadge'
import { ProBadge } from '@/components/ProBadge'
import { SectionAccordion } from '@/components/Section'
import { ExampleResponses } from '@/features/example-responses'
Expand Down Expand Up @@ -96,6 +97,7 @@ const handleDiscriminatorChange = (type: string) => {
</Badge>

<ProBadge :operation="operation" />
<BetaBadge :operation="operation" />

<Badge
v-if="isWebhook"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { computed, useId } from 'vue'
import { Anchor } from '@/components/Anchor'
import { Badge } from '@/components/Badge'
import OperationPath from '@/components/OperationPath.vue'
import { BetaBadge } from '@/components/BetaBadge'
import { ProBadge } from '@/components/ProBadge'
import {
Section,
Expand Down Expand Up @@ -78,6 +79,7 @@ const handleDiscriminatorChange = (type: string) => {
</Badge>

<ProBadge :operation="operation" />
<BetaBadge :operation="operation" />

<Badge
v-if="isWebhook"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,34 @@ const onAnchorClick = async (ev: Event) => {
<p class="sidebar-heading-link-title">
{{ item.title }}
</p>
<p
<div
v-if="'method' in item && !hasChildren"
class="sidebar-heading-link-method">
&hairsp;
<span class="sr-only">HTTP Method:&nbsp;</span>
<SidebarHttpBadge
class="min-w-9.75 justify-end text-right"
:active="isActive"
:method="item.method">
<template #default>
<ScalarIconWebhooksLogo
weight="bold"
v-if="'webhook' in item"
:style="{
color: getHttpMethodInfo(item.method).colorVar,
}" />
</template>
</SidebarHttpBadge>
</p>
<p class="sidebar-heading-link-method-row">
&hairsp;
<span class="sr-only">HTTP Method:&nbsp;</span>
<SidebarHttpBadge
class="min-w-9.75 justify-end text-right"
:active="isActive"
:method="item.method">
<template #default>
<ScalarIconWebhooksLogo
weight="bold"
v-if="'webhook' in item"
:style="{
color: getHttpMethodInfo(item.method).colorVar,
}" />
</template>
</SidebarHttpBadge>
</p>
<span
v-if="
'operation' in item && item.operation?.['x-api-beta'] === true
"
class="sidebar-beta-badge">
Beta
</span>
</div>
</a>
</div>
<slot v-if="open" />
Expand Down Expand Up @@ -178,6 +187,14 @@ const onAnchorClick = async (ev: Event) => {
}
.sidebar-heading-link-method {
margin: 0;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 2px;
flex-shrink: 0;
}
.sidebar-heading-link-method-row {
margin: 0;
}
.sidebar-heading.deprecated .sidebar-heading-link-title {
text-decoration: line-through;
Expand Down Expand Up @@ -352,4 +369,13 @@ const onAnchorClick = async (ev: Event) => {
color: var(--scalar-sidebar-color-1, var(--scalar-color-1));
font-weight: var(--scalar-sidebar-font-weight-active, var(--scalar-semibold));
}

.sidebar-beta-badge {
color: #9333ea;
font-size: 9px;
font-weight: var(--scalar-bold);
text-transform: uppercase;
line-height: 1;
flex-shrink: 0;
}
</style>