LogoLogo
  • Kaiko Knowledge Hub
  • General
    • 👋Introduction
    • 🏎️Getting Started
      • API input
      • API output
        • "taker_side_sell" Explained
        • Market open and close
        • Timestamp
      • Authentication
      • Data versioning
      • Envelope
      • Error codes
      • Pagination
      • Rate limiting
  • Data Feeds
    • Introduction
    • Level 1 & Level 2 Data
      • Level 1 Aggregations
        • Trade Count, OHLCV, & VWAP
          • OHLCV only
          • VWAP only
      • Level 1 Tick-Level
        • All trades
        • Derivative liquidation events
        • Borrows, repayments, liquidations, and withdrawals
      • Level 2 Aggregations
        • Market depth (snapshot)
        • Market depth (aggregation)
        • Price slippage (snapshot)
        • Price slippage (aggregation)
        • Bid-ask spread (aggregation)
        • Tokens in a liquidity pool
          • Tokens in a liquidity pool (Uniswap v3)
        • Interest rates, borrowed and deposited amounts
        • Raw order book snapshot
          • Raw order book snapshot + market depth, bid/ask spread & price slippage
      • Level 2 Tick-Level
        • Mints and burns
    • Reference Data
      • Free tier
        • Asset codes
        • Exchange codes
        • Exchange trading pair codes (instruments)
        • Lending protocol codes
        • Blockchain codes
      • Advanced tier
        • Derivatives contract details
        • Derivatives price details
      • Premium tier
        • Market capitalization and circulating supply (BETA)
  • ANALYTICS Solutions
    • Introduction
    • Kaiko Fair Market Value
      • Kaiko Fair Market Value (Direct prices for high liquidity pairs)
      • Kaiko Fair Market Value (Synthetic prices for low liquidity pairs)
        • Convert with Oanda FX Rates
    • Kaiko Derivatives Risk Indicators
      • Exchange-provided metrics
      • Token-level liquidation volumes
      • Implied volatility calculation - smile
      • Implied volatility calculation - surface
    • Kaiko Portfolio Risk & Performance
      • Value at risk calculation
      • Custom valuation
  • Monitoring Solutions
    • Kaiko Market Explorer
      • Assets
      • Exchanges
    • Kaiko Blockchain Monitoring
      • Ethereum Wallets
        • Balances and transactions
      • Bitcoin Wallets
        • Balances
        • Transaction
      • Solana Wallets
        • Balances and transactions
      • Provenance Wallets
        • Balances and transactions
  • Misc & Legacy endpoints
    • CME
Powered by GitBook
On this page
  • What is this endpoint for?
  • Endpoint
  • Parameters
  • Fields
  • Metadata information
  • Request example
  • Response example

Was this helpful?

Export as PDF
  1. Data Feeds
  2. Level 1 & Level 2 Data
  3. Level 2 Aggregations

Interest rates, borrowed and deposited amounts

What is this endpoint for?

This endpoint provides information about lending pools. It shows data such as how many tokens has been deposited and borrowed, as well as the interest rates for lending and borrowing at each block.

Endpoint

https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots

Parameters

Parameter
Mandatory?
Description
Example

blockchain

ethereum

protocol

One or several of the currently supported L&B protocols.

aav1

asset

L&B events including the requested token. Default: all available tokens.

tusd

live

Shows the data as soon as the block is validated. (Default: false, in case of block reorganization).

true

block_number

Block height.

10795593

start_block

Starting block height (inclusive).

129870

end_block

Ending block height (inclusive).

130000

start_time

Starting time in ISO 8601 (inclusive).

2022-04-01T00:00:00.000Z

end_time

Ending time in ISO 8601 (inclusive).

2022-05-01T00:00:00.000Z

interval

Interval between each snapshot. The suffixes are s (second), m (minute), h (hour), d (day), b (block), change (whenever a change happens). Default: 1b.

152s

sort

Returns the data in ascending or descending order. Default: desc.

ascending

page_size

1000

Fields

Field
Description
Example

blockchain

The blockchain on which the transaction happened.

ethereum

block_number

The height of the block in which the transaction happened.

16025918

datetime

The timestamp of the block in which the transaction happened.

1669124591

protocol

Code of the L&B protocol.

aave/v2

asset_symbol

Symbol of the underlying asset.

crv

asset_address

Address of the underlying asset.

0xd533a949740bb3306d119cc777fa900ba034cd52

asset_decimals

Decimals of the underlying asset.

18

receipt_symbol

Symbol of the receipt asset.

acrv

receipt_address

Address of the receipt asset.

0x8dae6cb04688c62d939ed9b68d32bc62e49970b1

receipt_decimals

Decimals of the receipt asset.

18

total_liquidity

The total amount of liquidity for this pool.

1486160

available_liquidity

The total amount of available liquidity for this pool.

1279630

total_borrowed

The total amount of tokens borrowed for this pool.

206535

supply_rate

The supply rate.

0.00289186

stable_borrow_rate

The stable borrow rate.

0.0442648

variable_borrow_rate

The variable borrow rate.

0.0208089

metadata

Metadata specific to each protocol.

More information below

Metadata information

AAVE v1

Field
Description
Example

total_borrowed_stable

The total amount of assets borrowed with a stable rate for this pool.

0

total_borrowed_variable

The total amount of assets borrowed with a variable rate for this pool.

41872.928778

AAVE v2

Field
Description
Example

total_borrowed_stable

The total amount of assets borrowed with a stable rate for this pool.

4162389.524515

total_borrowed_variable

The total amount of assets borrowed with a variable rate for this pool.

345075360.304631

total_reserves

Total liquidity - All of the debt tokens supply.

51387128.92415

Compound

Field
Description
Example

total_reserves

Total liquidity - All of the debt tokens supply.

3486037.365878

Cream

Field
Description
Example

total_reserves

Total liquidity - All of the debt tokens supply.

033661.402437

Maker

Field
Description
Example

collateral_ratio

Minimum ratio of collateral before liquidation.

1.5

debt_ceiling

Maximum amount of DAI that can be emitted on this type of vault.

2500000

debt_floor

Minimum amount of DAI that can be minted for this type of Vault.

2000

Request example

curl --compressed \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: <client-api-key>' \
  'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots?protocol=aav1&asset=tusd'
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum" 
protocol = "aav2"
asset = "tusd"

# ---- Optional parameters ---- #
user_address = None
live = "false"
tx_hash = None
block_number = None
start_block = None
end_block = None
start_time = "2025-03-01T13:00:00Z"
end_time = "2025-03-01T13:10:00Z"
sort = "desc"
page_size = 1000
interval = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, protocol: str, asset: str, user_address: str, live: str, tx_hash: str, block_number: int, start_block: int, end_block: int, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots'
    params = {
        "blockchain": blockchain,
        "protocol": protocol,
        "asset": asset,
        "user_address": user_address,
        "live": live,
        "tx_hash": tx_hash,
        "block_number": block_number,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "interval": interval,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, protocol=protocol, asset=asset, user_address=user_address, live=live, tx_hash=tx_hash, block_number=block_number, start_block=start_block, end_block=end_block, start_time=start_time, end_time=end_time, interval=interval, sort=sort, page_size=page_size)
print (df)

Response example

{
            "blockchain": "ethereum",
            "block_number": "21093894",
            "datetime": 1730477315,
            "market_id": "aave/v1/tusd",
            "protocol": "aav1",
            "asset_symbol": "tusd",
            "asset_address": "0x0000000000085d4780b73119b644ae5ecd22b376",
            "asset_decimals": "18",
            "receipt_symbol": "atusd",
            "receipt_address": "0x4da9b813057d04baef4e5800e36083717b4a0341",
            "receipt_decimals": "18",
            "available_liquidity": 293515.77258708066,
            "total_borrowed": 10897.083558481298,
            "total_liquidity": 304412.85614556196,
            "supply_rate": 0,
            "stable_borrow_rate": 0,
            "variable_borrow_rate": 0,
            "metadata": {
                "total_borrowed_stable": "0",
                "total_borrowed_variable": "10897.083558481297049061"
            }
        },
PreviousTokens in a liquidity pool (Uniswap v3)NextRaw order book snapshot

Last updated 2 months ago

Was this helpful?

One or several of the currently supported blockchain. Default: ethereum. See

Number of snapshots to return data for. (default: 100, min: 1, max: 1000). See

Blockchain codes
Pagination