DeFi Metrics

GET/gateway/v1/project/defi/metrics

Returns historical time-series for a single DeFi protocol metric (e.g. daily TVL). Each data point has a Unix timestamp and value.

Available metrics: `volume`, `fee`, `fees`, `revenue`, `tvl`, `users`.

Lookup: by UUID (`id`) or name (`q`). Filter by `chain` and date range (`from`/`to`). Returns 404 if the project is not found.

Pagination: check `meta.has_more`; when true, increase `offset` or `limit` to fetch the remaining points.

Note: this endpoint only returns data for DeFi protocol projects (e.g. `aave`, `uniswap`, `lido`, `makerdao`). Use `q` with a DeFi protocol name.

Query Parameters

idstring

Surf project UUID. PREFERRED — always use this when available from a previous response (e.g. project_id from /fund/portfolio or id from /search/project). Takes priority over q.

Example: 25c6612a-395c-4974-94eb-3b5f9f4b2ed7
qstring

Fuzzy entity name search. Only use when 'id' is not available. May return unexpected results for ambiguous names.

Example: uniswap
metricenum<string>

Metric to query. Can be `volume`, `fees` (or `fee` alias), `revenue`, `tvl`, or `users`. Defaults to tvl.

Available options:volumefeefeesrevenuetvlusers
Example: tvl
fromstring

Start of time range. Accepts Unix seconds (`1704067200`) or date string (`2024-01-01`)

Example: 2024-01-01
tostring

End of time range. Accepts Unix seconds (`1706745600`) or date string (`2024-02-01`)

Example: 2024-02-01
chainenum<string>

Filter by chain. Can be `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `base`, `avalanche`, `fantom`, or `solana`.

Available options:ethereumpolygonbscarbitrumoptimismbaseavalanchefantomsolana
Example: ethereum
limitinteger

Results per page

Example: 20
offsetinteger

Pagination offset

Example: 0
DeFi Metrics
const options = {method: 'GET'};

fetch('https://api.asksurf.ai/gateway/v1/project/defi/metrics?id=25c6612a-395c-4974-94eb-3b5f9f4b2ed7&q=uniswap&metric=tvl&from=2024-01-01&to=2024-02-01&chain=ethereum&limit=20&offset=0', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
OK
{
  "$schema": "https://example.com/schemas/DataResponseProjectMetricPoint.json",
  "data": [
    {
      "timestamp": 123,
      "value": 123
    }
  ],
  "meta": {
    "cached": true,
    "credits_used": 123,
    "empty_reason": "<string>",
    "has_more": true,
    "limit": 123,
    "offset": 123,
    "total": 123,
    "watermark": 123
  }
}