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
  • Request examples
  • Response example

Was this helpful?

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

Tokens in a liquidity pool

What is this endpoint for?

This indicates the amount of each token available for trading in a liquidity pool, identified through its blockchain pool address. A separate endpoint provides this data specifically for Uniswap V3 liquidity pools.

Endpoint

https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots

Parameters

Parameter
Required
Description
Example

blockchain

No

ethereum

pool_address

Yes

Pool address.

0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852

live

No

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

true

start_block

No

Starting block height (inclusive).

19645000

end_block

No

Ending block height (inclusive).

19645010

start_time

No

Starting time in ISO 8601 (inclusive).

2022-04-01T00:00:00.000Z

end_time

No

Ending time in ISO 8601 (inclusive).

2022-05-01T00:00:00.000Z

sort

No

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

asc

page_size

No

100

Fields

Field
Description
Example

blockchain

The blockchain on which the transaction happened.

ethereum

block_number

The height of the block.

129876

pool_name

Name of the pool as it is written on the blockchain.

WETH-USDT

pool_address

Address of the contract of the pool.

0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852

exchange

Code of the DEX.

usp2

amounts

Snapshot of the liquidity pool's tokens.

See example

datetime

Timestamp at which the interval begins. In seconds.

1650441900

Request examples

curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: KAIKO_API_KEY' \
  'https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots?pool_address=0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852&start_block=129870&end_block=129880'
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
pool_address = "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852"

# ---- Optional parameters ---- #
blockchain = "ethereum"
live = "false"
start_block = "129870"
end_block = "129880"
start_time = None
end_time = None
sort = "desc"
page_size = 100

# ---- 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, pool_address: str, blockchain: str, live: str, start_block: str, end_block: str, start_time: str, end_time: 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/liquidity.v1/snapshots'
    params = {
        "pool_address": pool_address,
        "blockchain": blockchain,
        "live": live,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "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, pool_address=pool_address, blockchain=blockchain, 
                   live=live, start_block=start_block, end_block=end_block, 
                   start_time=start_time, end_time=end_time, sort=sort, 
                   page_size=int(page_size))

Response example

{
    "query": {
        "blockchain": "ethereum",
        "protocol": "*",
        "pool_address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
        "start_block": "*",
        "end_block": "*",
        "start_time": "*",
        "end_time": "*",
        "live": "false",
        "sort": "descending",
        "page_size": "100",
        "live": "false"
    },
    "time": "2025-03-31T11:16:39.168Z",
    "timestamp": 1743419799,
    "data": [
        {
            "block_number": "22166374",
            "pool_name": "WETH-USDT",
            "pool_address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
            "exchange": "usp2",
            "price": 0.000553562,
            "amounts":
            [
                {
                    "symbol": "WETH",
                    "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                    "amount": 3005.5794298594374
                },
                {
                    "symbol": "USDT",
                    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                    "amount": 5389884.464753
                }
            ],
            "datetime": 1743417755,
            "blockchain": "ethereum"
        },
        ...
    ],
    "continuation_token": "xxx",
    "next_url": "https://us.market-api.kaiko.io/v2/data/liquidity.v1/snapshots?continuation_token=xxx"
}
PreviousBid-ask spread (aggregation)NextTokens in a liquidity pool (Uniswap v3)

Last updated 1 month ago

Was this helpful?

Should be one of the currently supported blockchains. See

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

Blockchain codes
Pagination