# 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.

Read our DEX liquidity snapshot data methodology [here](https://25446524.fs1.hubspotusercontent-eu1.net/hubfs/25446524/Case%20Studies%20%2B%20Data%20Gudies/DEX%20Methodology.pdf).&#x20;

### Endpoint

{% code overflow="wrap" %}

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

{% endcode %}

### Parameters

<table><thead><tr><th width="187">Parameter</th><th width="100">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>No</td><td>Should be one of the currently supported blockchains.<br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>pool_address</code></td><td>Yes</td><td>Pool address.</td><td><code>0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852</code></td></tr><tr><td><code>live</code></td><td>No</td><td>Shows the data as soon as the block is validated. (Default: false, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>start_block</code></td><td>No</td><td>Starting block height (inclusive).</td><td><code>19645000</code></td></tr><tr><td><code>end_block</code></td><td>No</td><td>Ending block height (inclusive).</td><td><code>19645010</code></td></tr><tr><td><code>start_time</code></td><td>No</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>No</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>sort</code></td><td>No</td><td>Returns the data in ascending (asc) or descending (desc) order. Default: desc.</td><td><code>asc</code></td></tr><tr><td><code>page_size</code></td><td>No</td><td>Number of snapshots to return data for. (default: 1000, min: 1, max: 1000). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>100</code></td></tr></tbody></table>

### Fields

<table><thead><tr><th width="184">Field</th><th width="309">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>The blockchain on which the transaction happened.</td><td><code>ethereum</code></td></tr><tr><td><code>block_number</code></td><td>The height of the block.</td><td><code>129876</code></td></tr><tr><td><code>pool_name</code></td><td>Name of the pool as it is written on the blockchain.</td><td><code>WETH-USDT</code></td></tr><tr><td><code>pool_address</code></td><td>Address of the contract of the pool.</td><td><code>0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852</code></td></tr><tr><td><code>exchange</code></td><td>Code of the DEX.</td><td><code>usp2</code></td></tr><tr><td><code>amounts</code></td><td>Snapshot of the liquidity pool's tokens.</td><td>See example</td></tr><tr><td><code>datetime</code></td><td>Timestamp at which the interval begins. In seconds.</td><td><code>1650441900</code></td></tr></tbody></table>

### Request examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
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'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 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))
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
    "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"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kaiko.com/rest-api/data-feeds/level-1-and-level-2-data/level-2-aggregations/tokens-in-a-liquidity-pool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
