# DeFi Chain Metrics API - TVL, Fees, Volume for Agents (`george.the.developer/defi-chain-metrics-api`) Actor

Real-time DeFi chain metrics for crypto trading agents. 16 metrics across 6 chains. Pay-per-call at $0.005. Data from DefiLlama, CoinGecko, Hyperliquid, Etherscan.

- **URL**: https://apify.com/george.the.developer/defi-chain-metrics-api.md
- **Developed by:** [George Kioko](https://apify.com/george.the.developer) (community)
- **Categories:** Other
- **Stats:** 1 total users, 1 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## DeFi Chain Metrics API

Real-time TVL, fees, volume, and on-chain data for 6 blockchains. Built for trading agents and DeFi dashboards.

A pay-per-call DeFi data API that serves blockchain metrics instantly via HTTP. No subscriptions, no rate-limit walls -- just `$0.005` per API call with data refreshed every 5 minutes from DefiLlama, CoinGecko, Hyperliquid, and Etherscan.

### What It Does

- **16 real-time metrics** per chain: TVL, stablecoin market cap, fees, revenue, DEX volume, perps volume, token price, market cap, and more
- **6 major blockchains** covered: Ethereum, Solana, BSC, Tron, Bitcoin, Arbitrum
- **Sub-second responses** via Apify Standby mode -- data is pre-cached and served instantly
- **Built for automation** -- trading bots, DeFi dashboards, portfolio trackers, and AI agents can query structured JSON without scraping

### Supported Chains

| Chain | Native Token | DeFi TVL Source | Explorer |
|-------|-------------|-----------------|----------|
| Ethereum | ETH | DefiLlama | Etherscan |
| Solana | SOL | DefiLlama | -- |
| BSC | BNB | DefiLlama | Etherscan v2 |
| Tron | TRX | DefiLlama | -- |
| Bitcoin | BTC | DefiLlama | -- |
| Arbitrum | ARB | DefiLlama | Etherscan v2 |

### Available Metrics

| ## | Metric Key | Description | Unit | Source |
|---|-----------|-------------|------|--------|
| 1 | `tvl` | Total Value Locked | USD | DefiLlama |
| 2 | `stablecoins_mcap` | Stablecoin market cap on chain | USD | DefiLlama |
| 3 | `chain_fees_24h` | Total chain fees (24h) | USD | DefiLlama |
| 4 | `chain_revenue_24h` | Chain revenue (24h) | USD | DefiLlama |
| 5 | `dex_volume_24h` | DEX trading volume (24h) | USD | DefiLlama |
| 6 | `perps_volume_24h` | Perpetuals volume (24h) | USD | Hyperliquid / DefiLlama |
| 7 | `token_incentives_24h` | Token incentives / bribes (24h) | USD | DefiLlama |
| 8 | `app_revenue_24h` | Application revenue (24h) | USD | DefiLlama |
| 9 | `app_fees_24h` | Application fees (24h) | USD | DefiLlama |
| 10 | `active_addresses_24h` | Active addresses (24h) | count | Etherscan |
| 11 | `new_addresses_24h` | New addresses (24h) | count | Etherscan |
| 12 | `transactions_24h` | Transaction count (24h) | count | Etherscan |
| 13 | `gas_used_24h` | Gas used (24h) | wei | Etherscan |
| 14 | `token_price` | Native token price | USD | DefiLlama / CoinGecko |
| 15 | `token_mcap` | Native token market cap | USD | CoinGecko |
| 16 | `token_volume_24h` | Native token trading volume (24h) | USD | CoinGecko |
| -- | `bridged_tvl` | Bridged TVL | USD | *Unavailable -- no free source* |
| -- | `net_inflows` | Net bridge inflows | USD | *Unavailable -- no free source* |

### API Endpoints

This is a Standby API actor. Once running, it exposes these HTTP endpoints:

#### Get all metrics for a chain

```bash
curl "https://gNoYlHf0L3druPJjI.apify.actor/metrics?chain=ethereum&token=YOUR_TOKEN"
````

#### Get a single metric

```bash
curl "https://gNoYlHf0L3druPJjI.apify.actor/metrics?chain=ethereum&metric=tvl&token=YOUR_TOKEN"
```

#### List all chains and their data status

```bash
curl "https://gNoYlHf0L3druPJjI.apify.actor/chains?token=YOUR_TOKEN"
```

#### Health check

```bash
curl "https://gNoYlHf0L3druPJjI.apify.actor/health?token=YOUR_TOKEN"
```

### Response Format

#### Full chain response (`/metrics?chain=ethereum`)

```json
{
  "chain": "ethereum",
  "chain_name": "Ethereum",
  "updated_at": "2026-04-04T05:31:48.331Z",
  "metrics": {
    "tvl": {
      "value": 52820000000,
      "formatted": "$52.82B",
      "unit": "USD"
    },
    "stablecoins_mcap": {
      "value": 165560000000,
      "formatted": "$165.56B",
      "unit": "USD"
    },
    "chain_fees_24h": {
      "value": 46010000,
      "formatted": "$46.01M",
      "unit": "USD",
      "change_1d": -5.2
    },
    "dex_volume_24h": {
      "value": 4460000000,
      "formatted": "$4.46B",
      "unit": "USD",
      "change_1d": 12.1
    },
    "token_price": {
      "value": 2050,
      "formatted": "$2.05K",
      "unit": "USD"
    },
    "token_mcap": {
      "value": 247650000000,
      "formatted": "$247.65B",
      "unit": "USD"
    },
    "perps_volume_24h": {
      "value": 2120000000,
      "formatted": "$2.12B",
      "unit": "USD",
      "source": "hyperliquid"
    }
  },
  "cache_age_seconds": 45,
  "is_stale": false
}
```

#### Single metric response (`/metrics?chain=ethereum&metric=tvl`)

```json
{
  "chain": "ethereum",
  "chain_name": "Ethereum",
  "metric": "tvl",
  "value": 52340000000,
  "formatted": "$52.34B",
  "unit": "USD",
  "updated_at": "2026-04-03T12:00:00.000Z",
  "cache_age_seconds": 45,
  "is_stale": false
}
```

### Pricing

**$0.005 per API call** -- pay-per-event via Apify platform billing.

| Usage | Monthly Cost |
|-------|-------------|
| 100 calls/day | $15/month |
| 500 calls/day | $75/month |
| 1,000 calls/day | $150/month |
| 5,000 calls/day | $750/month |

No subscriptions. No minimum commitment. You only pay for what you use.

### Why Not Just Use DefiLlama?

DefiLlama Pro API costs **$300/month** for unlimited access. This API serves the same underlying data per-call at **$0.005**.

A trading agent making **1,000 calls/day** pays ~**$150/month** -- 50% cheaper with no commitment. If you only need 100 calls/day, you pay just $15/month instead of $300.

For AI agents and bots that need structured blockchain metrics on demand, per-call pricing beats flat subscriptions every time.

### Architecture

```mermaid
graph LR
    A[Client / Trading Bot] -->|HTTP GET| B[Standby API Server]
    B -->|Read| C[Apify Key-Value Store]
    D[Refresh Loop] -->|Write every 5min| C
    D -->|Fetch| E[DefiLlama API]
    D -->|Fetch| F[CoinGecko API]
    D -->|Fetch| G[Hyperliquid API]
    D -->|Fetch| H[Etherscan v2 API]

    style B fill:#2563eb,color:#fff
    style C fill:#7c3aed,color:#fff
    style D fill:#059669,color:#fff
```

**Data flow:**

1. The **Refresh Loop** fetches metrics from 4 free data sources every 5 minutes
2. Metrics are cached in an **Apify Key-Value Store** per chain
3. The **Standby API Server** serves cached data instantly on HTTP GET requests
4. Each successful `/metrics` call charges `$0.005` via Apify pay-per-event billing

### Input Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `enabledChains` | array | All 6 chains | Which chains to fetch metrics for |
| `refreshIntervalMs` | integer | 300000 (5 min) | How often to refresh data from sources |
| `etherscanApiKey` | string | -- | Free API key from etherscan.io for on-chain metrics |

### Use Cases

- **Crypto trading bots** -- feed TVL and volume data into signal models
- **DeFi dashboards** -- display real-time chain metrics without managing data pipelines
- **Portfolio trackers** -- monitor token prices and market caps across chains
- **AI agents** -- structured JSON responses ready for LLM tool-use and function calling
- **Research** -- compare chain fees, revenue, and activity across L1s and L2s

### Keywords

DeFi data API, blockchain metrics API, TVL API, crypto trading data, chain fees API, DeFi dashboard data, on-chain analytics, Ethereum metrics, Solana metrics, BSC metrics, Bitcoin DeFi, Arbitrum data, DefiLlama alternative, crypto market data API, real-time blockchain data

# Actor input Schema

## `etherscanApiKey` (type: `string`):

Free API key from etherscan.io — needed for active addresses, transactions, gas metrics. Get one at https://etherscan.io/apis

## `enabledChains` (type: `array`):

Which chains to fetch metrics for

## `refreshIntervalMs` (type: `integer`):

How often to refresh data from sources (default 5 minutes)

## Actor input object example

```json
{
  "enabledChains": [
    "ethereum",
    "solana",
    "bsc",
    "bitcoin",
    "tron",
    "arbitrum"
  ],
  "refreshIntervalMs": 300000
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("george.the.developer/defi-chain-metrics-api").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("george.the.developer/defi-chain-metrics-api").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call george.the.developer/defi-chain-metrics-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=george.the.developer/defi-chain-metrics-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "DeFi Chain Metrics API - TVL, Fees, Volume for Agents",
        "description": "Real-time DeFi chain metrics for crypto trading agents. 16 metrics across 6 chains. Pay-per-call at $0.005. Data from DefiLlama, CoinGecko, Hyperliquid, Etherscan.",
        "version": "1.0",
        "x-build-id": "0MhTacETiflcpnPoh"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/george.the.developer~defi-chain-metrics-api/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-george.the.developer-defi-chain-metrics-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/george.the.developer~defi-chain-metrics-api/runs": {
            "post": {
                "operationId": "runs-sync-george.the.developer-defi-chain-metrics-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/george.the.developer~defi-chain-metrics-api/run-sync": {
            "post": {
                "operationId": "run-sync-george.the.developer-defi-chain-metrics-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "etherscanApiKey": {
                        "title": "Etherscan API Key",
                        "type": "string",
                        "description": "Free API key from etherscan.io — needed for active addresses, transactions, gas metrics. Get one at https://etherscan.io/apis"
                    },
                    "enabledChains": {
                        "title": "Enabled Chains",
                        "type": "array",
                        "description": "Which chains to fetch metrics for",
                        "default": [
                            "ethereum",
                            "solana",
                            "bsc",
                            "bitcoin",
                            "tron",
                            "arbitrum"
                        ]
                    },
                    "refreshIntervalMs": {
                        "title": "Refresh Interval (ms)",
                        "minimum": 60000,
                        "type": "integer",
                        "description": "How often to refresh data from sources (default 5 minutes)",
                        "default": 300000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
