This example shows how to extract DeFi data from DefiLlama using the DefiLlama Scraper actor on Apify — no browser automation or custom scraping code required.
- Calls the
piotrv1001/defillama-scraperApify actor with a simple input - Waits for the actor run to finish
- Fetches results from the Apify dataset
- Prints each item to the console
The actor handles all data collection across DefiLlama's endpoints: chains, protocols, DEXes, fees, and stablecoins.
- Node.js v18 or higher
- An Apify account
- Your Apify API token
npm installCopy .env.example to .env and add your Apify API token:
cp .env.example .envThen open .env and set your token:
APIFY_TOKEN=your_apify_token_here
npm startimport { ApifyClient } from 'apify-client';
import 'dotenv/config';
// Initialize the ApifyClient with your Apify API token
// Set APIFY_TOKEN in your .env file (copy .env.example to get started)
const client = new ApifyClient({
token: process.env.APIFY_TOKEN,
});
// Prepare Actor input
const input = {};
// Run the Actor and wait for it to finish
const run = await client.actor("piotrv1001/defillama-scraper").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/docsSee sample-output.json for a full example. The actor returns items across five data types:
| Type | Key fields |
|---|---|
| Chains | type, name, tvl, tokenSymbol, chainId, tvlChange1d, tvlChange7d, tvlChange30d, fees24h, fees7d, fees30d |
| Protocols | type, name, slug, symbol, category, chains, tvl, tvlChange1h, tvlChange1d, tvlChange7d, url, description, logo |
| DEXes | type, name, slug, chains, volume24h, volume7d, volume30d, volumeChange1d, volumeChange7d, volumeChange1m |
| Fees | type, name, slug, category, chains, fees24h, fees7d, fees30d, fees1y, feesAllTime, feesChange1d, feesChange7d |
| Stablecoins | type, name, symbol, pegType, pegMechanism, price, circulating, circulatingPrevDay, circulatingPrevWeek, chains |
- DeFi market monitoring — track TVL, volume, and fee trends across chains and protocols in real time
- Portfolio & risk analysis — compare protocol health metrics and stablecoin circulation for investment decisions
- Research & reporting — pull structured DeFi data into spreadsheets, dashboards, or data pipelines
- Stablecoin tracking — monitor peg stability and circulating supply changes across chains
- Competitive intelligence — compare DEX volumes, protocol fees, and chain growth over time
Open the DefiLlama Scraper on Apify
MIT
