# DefiLlama Protocol, Chain & Yield Data Extractor (`vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor`) Actor

Pull DeFi protocol TVL history, chain rankings, stablecoin supply, yield-pool APY, DEX and lending volume, fees, bridge flow, and token prices from DefiLlama's open datasets.

- **URL**: https://apify.com/vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor.md
- **Developed by:** [vexaloom-labs](https://apify.com/vexaloom-labs) (community)
- **Categories:** Developer tools, Automation, Other
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## DefiLlama Protocol, Chain & Yield Data Extractor

Pull live DeFi metrics straight from DefiLlama's open datasets — total value locked, stablecoin supply, yield-pool APY, DEX and lending volume, protocol fees, bridge flow, and token prices. Eighteen modes cover everything from one protocol's full TVL history to a ranked snapshot of every chain at once, with filters, deterministic sorting, and offset pagination on top.

### What this actor does

- **18 modes** spanning protocols, chains, stablecoins, yield pools, DEX/lending volume, fees, bridges, and token prices
- **Snapshot and history pairs** — e.g. `protocols` for current TVL across every project, `byProtocol` for one project's full TVL time series
- **`byUrl` auto-detect** — paste any defillama.com page URL and the actor chooses the right mode and identifier
- **Mode-aware filters** — name search, chain, category, minimum TVL, minimum APY, stablecoin-only pools, and project-scoped yields
- **Deterministic paging** — `sortBy` + `sortOrder` + `offset` + `maxItems` produce stable pages over a long result set
- **Legacy key support in code** — old key names still work without cluttering the input form
- **Empty fields are omitted** from every record

### Output per record

Every record carries `recordType`, `siteName: "DefiLlama"`, and `scrapedAt`, plus the fields below for its type.

**`protocol`** (modes `protocols`, `byProtocol`)

- `id`, `slug`, `name`, `symbol`, `address`, `description`, `url`, `logo`
- `chains[]`, `chain`, `category`, `module`, `parentProtocol`, `protocolType`, `isParentProtocol`, `misrepresentedTokens`
- `rank` (TVL rank across all protocols), `tvl`, `tvlUsd`, `chainTvls`, `currentChainTvls`
- `change1h`, `change1d`, `change7d`
- `marketCapUsd`, `fullyDilutedValuationUsd`
- `twitter`, `github[]`, `audits`, `auditLinks[]`, `governanceIds[]`, `methodology`
- `listedAt`, `listedAtIso`, `cmcId`, `cgId`, `raiseCount`, `hackCount`
- `defillamaUrl`

**`protocolHistory`** (mode `byProtocol`) — `slug`, `date`, `dateIso`, `tvlUsd`

**`chainTvl`** (mode `tvl`) — `name`, `tokenSymbol`, `chainId`, `cgId`, `gasTokenCgId`, `cmcId`, `rank`, `sharePct`, `tvlUsd`, `defillamaUrl`

**`chainHistory`** (mode `historicalChainTvl`) — `chain`, `date`, `dateIso`, `tvlUsd`

**`stablecoin`** (mode `stablecoins`) — `id`, `name`, `symbol`, `pegType`, `pegMechanism`, `chains[]`, `circulating`, `circulatingPrevDay`, `circulatingPrevWeek`, `circulatingPrevMonth`, `change1dPct`, `change7dPct`, `change30dPct`, `priceUsd` (when `stablecoinIncludePrices` is on), `delisted`, `defillamaUrl`

**`stablecoinChain`** (mode `stablecoinChains`) — `name`, `circulatingUSD` or per-currency `circulating<CODE>` fields

**`stablecoinPrice`** (mode `stablecoinPrices`) — `stablecoinId`, `name`, `symbol`, `currentPriceUsd`, `date`, `dateIso`, `circulatingUSD`

**`yieldPool`** (mode `yields`) — `pool`, `poolMeta`, `project`, `symbol`, `chain`, `tvlUsd`, `apy`, `apyBase`, `apyReward`, `apyBase7d`, `apyMean30d`, `apyChange1d`, `apyChange7d`, `apyChange30d`, `ilRisk`, `il7d`, `exposure`, `stablecoin`, `volume1dUsd`, `volume7dUsd`, `predictedClass`, `predictedProbability`, `binnedConfidence`, `rewardTokens[]`, `underlyingTokens[]`, `defillamaUrl`

**`yieldHistory`** (mode `yieldsByPool`) — `poolId`, `timestamp`, `apy`, `apyBase`, `apyReward`, `tvlUsd`

**`dexVolume`** (mode `dexVolumes`) — `name`, `displayName`, `module`, `category`, `protocolType`, `parentProtocol`, `logo`, `url`, `chains[]`, `volume24hUsd`, `volume48to24hUsd`, `volumeLastFullDayUsd`, `volume7dUsd`, `volume14dto7dUsd`, `volume30dUsd`, `volume60dto30dUsd`, `volume1yUsd`, `volumeAllTimeUsd`, `annualized1yUsd`, `average1yUsd`, `monthlyAverage1yUsd`, `change1d`, `change7d`, `change30d`, `change7dOver7d`, `change30dOver30d`, `defillamaUrl`

**`dexHistory`** (mode `dexByProtocol`) — `slug`, `timestamp`, `timestampIso`, `volumeUsd`

**`lendingMarket`** / **`lendingHistory`** (modes `lendingMarkets`, `lendingByProtocol`) — public protocol TVL data for lending-category protocols, with the same identity, chain, rank, TVL, and change fields as protocol records plus a daily `tvlUsd` history

**`fees`** (mode `fees`) — same shape as `dexVolume`, with `fees24hUsd`, `fees7dUsd`, `fees1yUsd`, etc. in place of `volume*Usd`

**`bridge`** (mode `bridges`) — `id`, `name`, `displayName`, `icon`, `chains[]`, `volumeLastDayUsd`, `volumeDayBeforeUsd`, `volumeWeeklyUsd`, `volumeMonthlyUsd`, `txsLastDay`, `txsWeekly`, `txsMonthly` (DefiLlama currently gates this dataset behind a paid plan)

**`bridgeHistory`** (mode `bridgeByName`) — `bridge`, `date`, `dateIso`, `depositUsd`, `withdrawUsd` (same paid-plan caveat)

**`tokenPrice`** (mode `currentPrices`) — `tokenId`, `symbol`, `priceUsd`, `decimals`, `timestamp`, `timestampIso`, `confidence`

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | string | `protocols` | One of the 18 modes listed above |
| `protocolSlug` | string | – | Protocol slug from its defillama.com URL, e.g. `aave` (modes `byProtocol` / `dexByProtocol` / `lendingByProtocol`) |
| `chain` | string | – | Required for `historicalChainTvl`; also filters protocols, chains, stablecoins, yields, DEX, lending, fees, and bridges by chain where available |
| `category` | string | – | Category filter for protocols, DEX, lending, and fee records, e.g. `Lending`, `Dexes` |
| `minTvlUsd` | int | – | Drop records below this TVL in USD (protocols / chains / yields / lending) |
| `searchQuery` | string | – | Case-insensitive name/symbol/project search across list modes |
| `minApy` | number | – | Minimum total APY for yield pools (mode `yields`) |
| `yieldStablecoinOnly` | boolean | `false` | Keep only stablecoin yield pools (mode `yields`) |
| `yieldProject` | string | – | Keep yield pools whose project slug contains this text (mode `yields`) |
| `stablecoinId` | int | – | DefiLlama stablecoin ID, e.g. `1` = USDT (mode `stablecoinPrices`) |
| `poolId` | string | – | Yield pool UUID from yields.llama.fi (mode `yieldsByPool`) |
| `bridgeName` | string | – | Bridge name from the bridges list (mode `bridgeByName`) |
| `tokenIds` | array | `[]` | Token IDs in `coingecko:bitcoin` / `ethereum:0x...` format, up to 100 (mode `currentPrices`) |
| `stablecoinIncludePrices` | boolean | `true` | Include current price per stablecoin (mode `stablecoins`) |
| `url` | string | – | Any defillama.com URL — mode and identifier are detected automatically (mode `byUrl`) |
| `maxItems` | int | `100` | Page size: hard cap on records emitted in this run |
| `offset` | int | `0` | Records to skip after filtering and sorting; page 2 means `offset = maxItems` |
| `sortBy` | string | – | Sort matching records before paging: TVL, APY, change, volume, fees, supply, price, market cap, date, timestamp, or name |
| `sortOrder` | string | `desc` | `desc` or `asc`; records with a missing value sort last |

#### Example: top lending protocols on Ethereum

```json
{
  "mode": "protocols",
  "chain": "Ethereum",
  "category": "Lending",
  "minTvlUsd": 1000000000,
  "sortBy": "tvlUsd",
  "sortOrder": "desc",
  "maxItems": 20
}
```

#### Example: second page of a long result set

```json
{
  "mode": "protocols",
  "sortBy": "tvlUsd",
  "sortOrder": "desc",
  "offset": 100,
  "maxItems": 100
}
```

#### Example: higher-yield stablecoin pools

```json
{
  "mode": "yields",
  "chain": "Ethereum",
  "minTvlUsd": 10000000,
  "minApy": 5,
  "yieldStablecoinOnly": true,
  "sortBy": "apy",
  "maxItems": 50
}
```

#### Example: full TVL history for one protocol

```json
{
  "mode": "byProtocol",
  "protocolSlug": "aave"
}
```

#### Example: auto-detect from a pasted URL

```json
{
  "mode": "byUrl",
  "url": "https://defillama.com/chain/Ethereum",
  "maxItems": 50
}
```

#### Example: current prices for a token list

```json
{
  "mode": "currentPrices",
  "tokenIds": ["coingecko:bitcoin", "coingecko:ethereum", "ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"]
}
```

### Legacy inputs

Saved tasks that still send old key names keep working: keys such as `limit` / `maxResults` (→ `maxItems`), `skip` / `start` (→ `offset`), `protocol` / `slug` (→ `protocolSlug`), `chainName` (→ `chain`), `minTVL` (→ `minTvlUsd`), `pool` (→ `poolId`), `bridge` (→ `bridgeName`), `tokens` (→ `tokenIds`), `includePrices` (→ `stablecoinIncludePrices`), `search` / `query` (→ `searchQuery`), `project` (→ `yieldProject`), `stablecoinOnly` (→ `yieldStablecoinOnly`), and `sort` / `order` are mapped in code. Old identifiers such as `mode: "protocol"` or `mode: "yield"` are also understood by the code path, but the input schema validates `mode` against the canonical list, so use the canonical mode value in new runs.

### Use cases

- **Treasury dashboards** — pull chain and protocol TVL on a schedule to track exposure
- **Yield scouting** — rank stablecoin pools by APY with TVL floors, then page through the tail
- **DeFi research reports** — combine DEX volume, fees, and lending TVL for market-structure analysis
- **Bridge-flow monitoring** — watch deposit/withdraw volume when the upstream dataset allows it
- **Portfolio pricing** — look up current USD prices for a basket of tokens by ID

### FAQ

**Do I need an API key?**
No. Every mode reads DefiLlama's free public datasets and runs cookielessly.

**How do I paginate?**
Sort first (`sortBy` + `sortOrder`), then set `offset` and `maxItems`. Without a sort the source order is preserved, which may change between runs.

**How do I find `protocolSlug`, `poolId`, or `bridgeName`?**
Copy the slug straight out of a defillama.com URL (e.g. `defillama.com/protocol/aave` → `aave`), or paste the whole URL into `mode: "byUrl"` and let the actor work it out.

**Why doesn't `mode=protocols` include a TVL history?**
It returns the current snapshot (with 1h/1d/7d change) for every protocol in one call. For the full time series, use `mode=byProtocol` with a `protocolSlug`.

**What happened to the lending modes?**
DefiLlama's lending overview/summary endpoints currently return HTTP 500. The actor derives lending markets and history from public protocol TVL data for lending-category protocols instead, and says so in the run status. No cookie or key is involved.

**Why are `bridges` and `bridgeByName` empty?**
DefiLlama moved bridge volume and transaction history behind a paid plan. The run finishes cleanly with a status message explaining the limit; every other mode is unaffected.

**Why do some chains show no TVL in `mode=tvl`?**
Chains with zero reported TVL are dropped so the dataset stays free of placeholder rows.

**Is price data live?**
Yes for `currentPrices` — it reflects DefiLlama's latest aggregated quote, including a `confidence` score; values below `0.5` may be stale upstream.

**Is this affiliated with DefiLlama?**
No. This is a third-party actor built on DefiLlama's publicly documented datasets; it is not affiliated with or endorsed by DefiLlama.

# Actor input Schema

## `mode` (type: `string`):

What to fetch.

## `protocolSlug` (type: `string`):

DefiLlama protocol slug — visible in the URL on defillama.com (e.g. `aave`, `lido`, `uniswap`, `curve-dex`). Example: `aave`.

## `chain` (type: `string`):

Chain name as DefiLlama uses it. Required for `historicalChainTvl`; also filters protocols, chains, stablecoins, yields, DEX, lending, fees, and bridges by chain where the source exposes it. Use the dropdown for top chains, OR paste an exact chain name from the chains list (case-sensitive — DefiLlama uses `Ethereum`, `BSC`, etc.).

## `category` (type: `string`):

Filter records by DefiLlama category (e.g. `Lending`, `Dexes`, `Liquid Staking`, `Yield Aggregator`, `Bridge`, `CDP`, `Yield`, `Derivatives`, `Cross Chain`).

## `minTvlUsd` (type: `integer`):

Drop records with TVL below this threshold (USD).

## `searchQuery` (type: `string`):

Case-insensitive text match on name, symbol, or project — e.g. `aave`, `uniswap`, `USDC`.

## `minApy` (type: `number`):

Drop yield pools whose total APY is below this percentage. Applies to `mode=yields` only.

## `yieldStablecoinOnly` (type: `boolean`):

Keep only yield pools where DefiLlama marks the underlying asset as a stablecoin.

## `yieldProject` (type: `string`):

Only keep yield pools from projects whose slug contains this text, e.g. `aave`, `lido`, `curve`.

## `stablecoinId` (type: `integer`):

DefiLlama stablecoin ID (e.g. `1` = USDT, `2` = USDC). See `mode=stablecoins` to enumerate.

## `poolId` (type: `string`):

DefiLlama yield pool UUID (visible in the pool URL on yields.llama.fi).

## `bridgeName` (type: `string`):

Bridge identifier from the bridges list.

## `tokenIds` (type: `array`):

List of token IDs in DefiLlama format: `coingecko:bitcoin`, `ethereum:0x...`, `bsc:0x...`. Up to 100 per call.

## `stablecoinIncludePrices` (type: `boolean`):

When true, the stablecoins endpoint includes current price data per asset.

## `url` (type: `string`):

Any defillama.com URL — auto-detected. Examples: defillama.com/protocol/aave , defillama.com/chain/Ethereum , stablecoins.llama.fi (homepage → top stablecoins).

## `maxItems` (type: `integer`):

Hard cap on records emitted in this run. Combine with `offset` to page through a long result set. Example: `100`.

## `offset` (type: `integer`):

Skip this many records after filtering and sorting, then emit up to `maxItems`. Page 2 with `maxItems=100` means `offset=100`.

## `sortBy` (type: `string`):

Sort matching records before applying `offset` and `maxItems`. Leave empty to keep the source order.

## `sortOrder` (type: `string`):

Direction used when `sortBy` is set. Records with a missing sort value are placed last.

## Actor input object example

```json
{
  "mode": "protocols",
  "chain": "",
  "category": "",
  "yieldStablecoinOnly": false,
  "tokenIds": [],
  "stablecoinIncludePrices": true,
  "maxItems": 3,
  "offset": 0,
  "sortBy": "",
  "sortOrder": "desc"
}
```

# Actor output Schema

## `records` (type: `string`):

Dataset containing all scraped DefiLlama records.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "protocols",
    "chain": "",
    "category": "",
    "yieldStablecoinOnly": false,
    "tokenIds": [],
    "stablecoinIncludePrices": true,
    "maxItems": 3,
    "offset": 0,
    "sortBy": "",
    "sortOrder": "desc"
};

// Run the Actor and wait for it to finish
const run = await client.actor("vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "protocols",
    "chain": "",
    "category": "",
    "yieldStablecoinOnly": False,
    "tokenIds": [],
    "stablecoinIncludePrices": True,
    "maxItems": 3,
    "offset": 0,
    "sortBy": "",
    "sortOrder": "desc",
}

# Run the Actor and wait for it to finish
run = client.actor("vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "protocols",
  "chain": "",
  "category": "",
  "yieldStablecoinOnly": false,
  "tokenIds": [],
  "stablecoinIncludePrices": true,
  "maxItems": 3,
  "offset": 0,
  "sortBy": "",
  "sortOrder": "desc"
}' |
apify call vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/defillama-protocol-chain-and-yield-data-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/3reMqRFfQdnztHOtf/builds/gSwiMv6IAfamCsQ2k/openapi.json
