Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to DefiLlama

Scalekit connector
Open markdown

The DefiLlama connector lets your AI agent work with DefiLlama. It needs no sign-in. It comes with 25 tools.

Tools
25
What they doRead · write · destructive
25 · 0 · 025 read0 write0 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the DefiLlama connection

    In AgentKit > Connections, create a DefiLlama connection. The name you give it is the connection_name your code passes. See Configure connections.

    Users don't sign in to DefiLlama, so the connection needs no credentials.

  4. Make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'defillama'
    const identifier = 'user_123'
    // Create the user's connected account. No sign-in is needed, so it's active right away.
    await actions.getAuthorizationLink({ connectionName: connector, identifier })
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'defillama_get_dexs_overview',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Requesting the link creates the user's connected account; there's nothing to open. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • defillama_get_batch_historical_pricesGet historical USD prices for several tokens, each at its own list of timestamps, in one call.Read-only

    Get Batch Historical Prices

    Get historical USD prices for several tokens, each at its own list of timestamps, in one call. Returns coins, keyed by coin id, each with symbol and a prices array of {timestamp, price, confidence}, one entry per requested timestamp. Use defillama_get_batch_historical_prices when coins need different timestamps. Use defillama_get_historical_prices when every coin shares one timestamp.

    Inputs

    coinsobjectrequired
    JSON object whose keys are coin ids ({chain}:{address} or coingecko:{id}) and whose values are arrays of unix timestamps in seconds. Send it as an object or as the equivalent JSON text. Example: {"coingecko:ethereum": [1666869543, 1666862343], "avax:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e": [1666876743]}.
  • defillama_get_chain_dexs_overviewGet trading volume for every DEX on one chain.Read-only

    Get Chain DEX Volume Overview

    Get trading volume for every DEX on one chain. Returns totals for the last 24 hours, 7 days, 30 days, 1 year and all time (total24h, total7d, total30d, total1y, totalAllTime) with change_1d, change_7d and change_1m, allChains, and protocols: one row per protocol with name, slug, category, chains and the same totals and changes. Volumes count only trades on that chain. Use defillama_get_chain_dexs_overview to rank DEXs on one chain. Use defillama_get_dexs_overview for all chains and defillama_get_dex_summary for one DEX.

    Inputs

    chainstringrequired
    Chain name as DefiLlama lists it, case-insensitive, for example Ethereum, Arbitrum, BSC or Solana. Get valid names from the allChains field of defillama_get_dexs_overview.
    exclude_total_data_chartboolean
    true (default) leaves out totalDataChart, the daily history of the summed value, and returns only the current totals and the per-protocol rows. Set false to add the daily history.default true
    exclude_total_data_chart_breakdownboolean
    true (default) leaves out totalDataChartBreakdown, the daily history split by protocol. Setting false can make the response several megabytes, which can exceed Scalekit's response size limit on large chains or on the all-chains overview.default true
  • defillama_get_chain_fees_overviewGet fees, revenue or holders revenue for every protocol on one chain.Read-only

    Get Chain Fees Overview

    Get fees, revenue or holders revenue for every protocol on one chain. Returns totals for the last 24 hours, 7 days, 30 days, 1 year and all time with change_1d, change_7d and change_1m, allChains, and protocols: one row per protocol with name, slug, category, chains, methodology and the same totals, all in USD for the chosen data_type. Use defillama_get_chain_fees_overview to rank protocols on a chain by fees or revenue and to find protocol slugs. Use defillama_get_fees_summary for one protocol's history.

    Inputs

    chainstringrequired
    Chain name as DefiLlama lists it, case-insensitive, for example Ethereum, Arbitrum, BSC or Solana. Get valid names from the name field of defillama_list_chains.
    data_typestring
    Which metric to report: dailyFees (all fees users pay, the default), dailyRevenue (the share the protocol keeps), or dailyHoldersRevenue (the share paid to token holders through buybacks, burns or distributions). Omit for dailyFees.one of dailyFeesdailyRevenuedailyHoldersRevenue
    exclude_total_data_chartboolean
    true (default) leaves out totalDataChart, the daily history of the summed value, and returns only the current totals and the per-protocol rows. Set false to add the daily history.default true
    exclude_total_data_chart_breakdownboolean
    true (default) leaves out totalDataChartBreakdown, the daily history split by protocol. Setting false can make the response several megabytes, which can exceed Scalekit's response size limit on large chains or on the all-chains overview.default true
  • defillama_get_chain_historical_tvlGet the daily total value locked of one blockchain's DeFi protocols.Read-only

    Get Chain Historical TVL

    Get the daily total value locked of one blockchain's DeFi protocols. Returns array: {date, tvl} points, date as a unix timestamp and tvl in USD. Liquid staking and double-counted TVL are excluded. Use defillama_get_chain_historical_tvl for one chain's trend. Use defillama_get_historical_tvl for all chains combined, and defillama_list_chains for every chain's current TVL.

    Inputs

    chainstringrequired
    Chain name as DefiLlama lists it, case-insensitive, for example Ethereum, Arbitrum, BSC or Solana. Get valid names from the name field of defillama_list_chains.
  • defillama_get_chain_options_overviewGet trading volume for every options exchange on one chain.Read-only

    Get Chain Options Volume Overview

    Get trading volume for every options exchange on one chain. Returns totals for the last 24 hours, 7 days, 30 days, 1 year and all time (total24h, total7d, total30d, total1y, totalAllTime) with change_1d, change_7d and change_1m, allChains, and protocols: one row per protocol with name, slug, category, chains and the same totals and changes. Values are notional volume unless data_type is dailyPremiumVolume. Use defillama_get_chain_options_overview for one chain. Use defillama_get_options_overview for all chains and defillama_get_options_summary for one venue.

    Inputs

    chainstringrequired
    Chain name as DefiLlama lists it, case-insensitive, for example Ethereum, Arbitrum, BSC or Solana. Get valid names from the allChains field of defillama_get_options_overview.
    data_typestring
    Which options volume to report: dailyNotionalVolume (value of the underlying assets traded, the default) or dailyPremiumVolume (premiums paid for the options). Omit for dailyNotionalVolume.one of dailyPremiumVolumedailyNotionalVolume
    exclude_total_data_chartboolean
    true (default) leaves out totalDataChart, the daily history of the summed value, and returns only the current totals and the per-protocol rows. Set false to add the daily history.default true
    exclude_total_data_chart_breakdownboolean
    true (default) leaves out totalDataChartBreakdown, the daily history split by protocol. Setting false can make the response several megabytes, which can exceed Scalekit's response size limit on large chains or on the all-chains overview.default true
  • defillama_get_chain_stablecoin_market_cap_historyGet the daily circulating supply of stablecoins on one chain, for all stablecoins or one.Read-only

    Get Chain Stablecoin Market Cap History

    Get the daily circulating supply of stablecoins on one chain, for all stablecoins or one. Returns array: daily points with date (unix timestamp as a string) and totalCirculating, totalCirculatingUSD, totalMintedUSD, and on later points totalBridgedToUSD and totalUnreleased, each keyed by peg type. Use defillama_get_chain_stablecoin_market_cap_history for one chain. Use defillama_get_stablecoin_market_cap_history for all chains combined, and defillama_list_stablecoin_chains for today's totals per chain.

    Inputs

    chainstringrequired
    Chain name as DefiLlama lists it, case-insensitive, for example Ethereum, Arbitrum, BSC or Solana. Get valid names from the name field of defillama_list_stablecoin_chains.
    stablecoininteger
    Numeric DefiLlama stablecoin id to restrict the history to one stablecoin, for example 1 for USDT or 2 for USDC. Get ids from the id field of defillama_list_stablecoins. Omit to sum every stablecoin.
  • defillama_get_closest_blockFind the block on a chain whose time is closest to a given unix timestamp.Read-only

    Get Closest Block

    Find the block on a chain whose time is closest to a given unix timestamp. Returns height (the block number) and timestamp (that block's unix time). Use defillama_get_closest_block to turn a date into a block number for on-chain queries.

    Inputs

    chainstringrequired
    Chain identifier in lowercase, as used in coin ids, for example ethereum, bsc, polygon, arbitrum, avax or optimism.
    timestampintegerrequired
    Unix timestamp in seconds to look up, for example 1603964988.
  • defillama_get_current_pricesGet the current USD price of one or more tokens, by contract address or CoinGecko id.Read-only

    Get Current Prices

    Get the current USD price of one or more tokens, by contract address or CoinGecko id. Returns coins, keyed by the coin id you sent, each with price in USD, symbol, decimals (contract tokens only), timestamp of the price and confidence (0 to 1; lower for prices derived from thin on-chain liquidity). Use defillama_get_current_prices for spot prices. Use defillama_get_historical_prices for one past moment, defillama_get_price_chart for a series, and defillama_get_price_percentage_change for a change over a period.

    Inputs

    coinsstringrequired
    Comma-separated list of coins, no spaces. Each coin is {chain}:{token contract address} (for example ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 for USDC on Ethereum, or bsc:0x762539b45a1dcce3d36d080f74d1aed37844b878), or coingecko:{CoinGecko id} for native and well-known assets (for example coingecko:ethereum, coingecko:bitcoin). Example: coingecko:ethereum,ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48. A coin DefiLlama cannot price is left out of the response rather than causing an error.