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
  • Path Parameters
  • Query Parameters
  • Fields
  • Request examples
  • Response example

Was this helpful?

Export as PDF
  1. Data Feeds
  2. Level 1 & Level 2 Data
  3. Level 1 Tick-Level

Derivative liquidation events

Each and every derivative liquidation event

PreviousAll tradesNextBorrows, repayments, liquidations, and withdrawals

Last updated 2 months ago

Was this helpful?

What is this endpoint for?

This endpoint returns all derivative liquidation events for a given instrument on an exchange. It includes all details available for the event like price and position. Data is available for futures and perpetual futures. For exchange coverage, see .

Endpoint

https://{region}.market-api.kaiko.io/v2/data/liquidation.v1/trades/{exchange}/{instrument_class}/{instrument}

Path Parameters

Parameter
Required?
Example

region

Yes

Choose between: eu us

exchange

Yes

instrument_class

Yes

Choose between : future perpetual-future

instrument

Yes

Query Parameters

Parameter
Required
Description
Example

start_time

No

Starting time in ISO 8601 (inclusive). Automatically included in continuation tokens.

2025-01-23T00:01:00.000Z

end_time

No

Ending time in ISO 8601 (exclusive). Automatically included in continuation tokens.

2025-02-25T23:59:00.000Z

sort

No

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

asc

page_size

No

Maximum: 1000

500

Fields

Field
Description
Example

amount

The quantity, displayed in base currency.

0.113

amount_quote

The quantity, displayed in the quote asset.

9362.592400000001

amount_usd

The quantity, displayed in USD.

9359.689996356

price

The price at which the liquidation was executed, displayed in USD.

82854.8

rate

Rate used to convert quote currency to USD. For example: 1 USDT = 0.997 USD

0.99969

position_side

The position liquidated

long

timestamp

The timestamp provided by the exchange or the collection timestamp in Unix Timestamp (in milliseconds)

1741785829372000000

trade_id

Unique trade ID (unique to the exchange). In case the exchange does not provide an ID, we generate it ourselves.

d472cae0135..dfdh6_g

Request examples

curl --compressed -H 'Accept: application/json' -H 'X-Api-Key: <client-api-key>' \
'https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/bbit/perpetual-future/eth-usdt?start_time=2025-04-12T00:00:00Z&end_time=2025-04-12T08:00:00Z&page_size=10'
##### 1. Import dependencies #####
import requests
import pandas as pd
from urllib.parse import urlencode

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
exchange = "bbit"
instrument_class = "perpetual-future"
instrument = "eth-usdt"

# ---- Optional parameters ---- #
page_size = 10
sort = "desc"
start_time = "2025-04-12T00:00:00Z"
end_time = "2025-04-12T08:00:00Z"

# ---- 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_liquidation_trades(api_key: str, exchange: str, instrument_class: str, instrument: str, 
                                 start_time: str, end_time: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    base_url = f'https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/{exchange}/{instrument_class}/{instrument}'
    params = {
        "start_time": start_time,
        "end_time": end_time,
        "sort": sort,
        "page_size": page_size
    }
    
    # Debug: Show the URL being generated
    query_string = urlencode(params)
    full_url = f"{base_url}?{query_string}"
    print(f"DEBUG - Making request to URL: {full_url}")
    print(f"DEBUG - Headers: {headers}")
    
    try:
        res = requests.get(base_url, headers=headers, params=params)
        
        # Debug: Show the actual URL that requests used
        print(f"DEBUG - Actual request URL: {res.url}")
        print(f"DEBUG - Response status code: {res.status_code}")
        
        res.raise_for_status() 
        data = res.json()
        
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
            
        df = pd.DataFrame(data['data'])
        print(f"DEBUG - Initial data fetch successful, got {len(df)} records")
        
        # Handle pagination with continuation token
        page_count = 1
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
                
            print(f"DEBUG - Fetching page {page_count + 1} with URL: {next_url}")
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            
            if 'data' in data:
                new_records = len(data['data'])
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
                print(f"DEBUG - Fetched additional {new_records} records, total now: {len(df)}")
                page_count += 1
            else:
                print("DEBUG - No more data in pagination response")
                break
        
        return df
    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        print(f"Response status code: {e.response.status_code if hasattr(e, 'response') else 'N/A'}")
        print(f"Response text: {e.response.text if hasattr(e, 'response') else 'N/A'}")
        return pd.DataFrame() 

# ---- Get the data ---- #
print("Starting API request...")
df = get_kaiko_liquidation_trades(
    api_key=api_key, 
    exchange=exchange,
    instrument_class=instrument_class,
    instrument=instrument,
    start_time=start_time, 
    end_time=end_time,
    sort=sort, 
    page_size=page_size
)

Response example

```json
{
   "query": {
      "exchange": "bbit",
      "instrument": "eth-usdt",
      "instrument_class": "perpetual-future",
      "commodity": "liquidationEvents",
      "request_time": "2025-04-04T11:58:32.545Z",
      "start_time": "2025-02-12T00:00:01.000Z",
      "start_timestamp": 1739318401000,
      "end_time": "2025-02-24T23:59:37.000Z",
      "end_timestamp": 1740441577000,
      "page_size": 10,
      "sort": "desc",
      "data_version": "v1"
   },
   "answer_time": "2025-04-04T11:58:32.554Z",
   "answer_timestamp": 1743767912554,
   "access": {
      "access_range": {
         "start_timestamp": 1688428800000,
         "end_timestamp": 2177539199000
      },
      "data_range": {
         "start_timestamp": null,
         "end_timestamp": null
      }
   },
   "data": [
      {
         "amount": 0.1,
         "amount_quote": 249.77100000000002,
         "amount_usd": 249.76370743089532,
         "price": 2497.71,
         "rate": 0.9999708029791101,
         "position_side": "long",
         "timestamp": 1740441553739,
         "trade_id": "376def42502a7a307b85d7ffdebec8c8c08990b19f6fb165e0f97c8fd058a1b2"
      },
      {
         "amount": 0.04,
         "amount_quote": 99.7556,
         "amount_usd": 99.75268743366291,
         "price": 2493.89,
         "rate": 0.9999708029791101,
         "position_side": "long",
         "timestamp": 1740441446020,
         "trade_id": "f1062a8c42743ffbddc3d129d65f1ae6848227b871361d6fd66f3bbbbb4b10da"
      },
        /*---*/
    ],
    */....
    
"continuation_token": "3RuQ1KYk3AEZTJXXqsaUMrdUKSYH4CVdGUFQCZC5pts7AYMafCjbnYSuedeLMFu72PsXKepcvdtpvZmNzXmotWV1ARAF8hJxLfaDXn75MmkN3zMq6ma9Ym",
   "next_url": "https://us.market-api.kaiko.io/v2/data/liquidation.v1/trades/bbit/perpetual-future/eth-usdt?continuation_token=3RuQ1KYk3AEZTJXXqsaUMrdUKSYH4CVdGUFQCZC5pts7AYMafCjbnYSuedeLMFu72PsXKepcvdtpvZmNzXmotWV1ARAF8hJxLfaDXn75MmkN3zMq6ma9Ym"
}

Exchange code. See

Instrument code. See

See Default: 100

Exchange codes
Exchange trading pair codes (instruments)
Pagination
Derivatives markets - centralized