{
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "title": "Detail",
            "type": "array"
          }
        },
        "title": "HTTPValidationError",
        "type": "object"
      },
      "ValidationError": {
        "properties": {
          "ctx": {
            "title": "Context",
            "type": "object"
          },
          "input": {
            "title": "Input"
          },
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "title": "Location",
            "type": "array"
          },
          "msg": {
            "title": "Message",
            "type": "string"
          },
          "type": {
            "title": "Error Type",
            "type": "string"
          }
        },
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError",
        "type": "object"
      }
    }
  },
  "externalDocs": {
    "description": "CLI, MCP server and npm package",
    "url": "https://liquidations.dev/en/mcp"
  },
  "info": {
    "contact": {
      "name": "liquidations.dev",
      "url": "https://liquidations.dev/en/api"
    },
    "description": "Liquidation data from 10 exchanges: Binance, Bybit, OKX, Bitget and Gate\nare read directly, Hyperliquid, HTX, Lighter, Aster and Bitfinex through aggregated feeds.\nHistory since November 2023.\n\n**Authentication.** Every request carries the header `X-API-Key` with a key from the\naccount. A free key allows 5 requests per minute and the last 24 hours; paid plans go up\nto 1200 requests per minute with the full history.\n\n**Errors.** JSON body `{\"detail\": {\"error\": \"<code>\", \"message\": \"...\"}}` with one of the\ncodes `missing_key`, `invalid_key`, `revoked`, `plan_window`, `rate_limited`,\n`ip_blocked`. Status 422 means an invalid query parameter.\n\n**Times** are milliseconds since epoch.\n\n**Optional header** `X-Client: cli | mcp | ext` tags a request for usage statistics.\n\nThe WebSocket stream is documented at https://liquidations.dev/en/api.\n\n**CLI and MCP server.** The open source npm package `liquidations-dev` (MIT) wraps this API for the\nterminal and for AI assistants: https://liquidations.dev/en/mcp.\n",
    "title": "liquidations.dev API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/v1/agg/1m": {
      "get": {
        "description": "Liquidation totals per minute in USD, newest first: number of events, long side, short side and total. `m` is the start of the minute, ms epoch. With `symbol` and `exchange` both set, rows cover that pair only; without them, rows sum all exchanges and coins. Results are cached for 60 seconds.",
        "operationId": "get_liquidation_summary",
        "parameters": [
          {
            "description": "Base coin: `BTC` or `BTCUSDT` both work",
            "in": "query",
            "name": "symbol",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Base coin: `BTC` or `BTCUSDT` both work",
              "title": "Symbol"
            }
          },
          {
            "description": "Exchange id, see /liquidations",
            "in": "query",
            "name": "exchange",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exchange id, see /liquidations",
              "title": "Exchange"
            }
          },
          {
            "description": "Start of the window, ms epoch",
            "in": "query",
            "name": "f",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Start of the window, ms epoch",
              "title": "F"
            }
          },
          {
            "description": "End of the window, ms epoch. Defaults to now",
            "in": "query",
            "name": "t",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "End of the window, ms epoch. Defaults to now",
              "title": "T"
            }
          },
          {
            "description": "Maximum number of minute buckets",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 500,
              "description": "Maximum number of minute buckets",
              "maximum": 1000,
              "minimum": 1,
              "title": "Limit",
              "type": "integer"
            }
          },
          {
            "description": "API key of the account (starts with `liq_`)",
            "in": "header",
            "name": "x-api-key",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "API key of the account (starts with `liq_`)",
              "title": "X-Api-Key"
            }
          },
          {
            "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
            "in": "header",
            "name": "x-client",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
              "title": "X-Client"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "cnt": 132,
                      "long_usd": 4821100.5,
                      "m": 1764640000000,
                      "short_usd": 1920400.25,
                      "vol_usd": 6741500.75
                    }
                  ],
                  "meta": {
                    "count": 1,
                    "interval": "1m",
                    "plan": "free"
                  }
                },
                "schema": {}
              }
            },
            "description": "Minute buckets, newest first"
          },
          "401": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "invalid_key",
                    "message": "unknown API key",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `invalid_key`: unknown API key"
          },
          "403": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "plan_window",
                    "message": "free plan allows a 24h history window",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `plan_window`: free plan allows a 24h history window"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          },
          "429": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "ip_blocked",
                    "message": "too many requests with invalid keys from this address",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `ip_blocked`: too many requests with invalid keys from this address"
          }
        },
        "summary": "Minute aggregates"
      }
    },
    "/api/v1/liquidations": {
      "get": {
        "description": "Newest first, one row per forced liquidation event. `symbol` is the base coin. `ts` and the window are milliseconds since epoch. `vol_usd` can be null when the exchange feed lacks the data (`completeness` = `partial`). Free keys see the last 24 hours; paid plans see the full history since November 2023.",
        "operationId": "get_liquidations",
        "parameters": [
          {
            "description": "Exchange id: binance, bybit, okx, bitget, gate, hyperliquid, htx, lighter, aster, bitfinex",
            "in": "query",
            "name": "exchange",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Exchange id: binance, bybit, okx, bitget, gate, hyperliquid, htx, lighter, aster, bitfinex",
              "title": "Exchange"
            }
          },
          {
            "description": "Base coin: `BTC` or `BTCUSDT` both work",
            "in": "query",
            "name": "symbol",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Base coin: `BTC` or `BTCUSDT` both work",
              "title": "Symbol"
            }
          },
          {
            "description": "Position side that was liquidated",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "pattern": "^(long|short)$",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Position side that was liquidated",
              "title": "Side"
            }
          },
          {
            "description": "Minimum USD value of an event",
            "in": "query",
            "name": "min_vol",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "minimum": 0,
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Minimum USD value of an event",
              "title": "Min Vol"
            }
          },
          {
            "description": "Start of the window, ms epoch. Defaults to the start of the plan window",
            "in": "query",
            "name": "f",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Start of the window, ms epoch. Defaults to the start of the plan window",
              "title": "F"
            }
          },
          {
            "description": "End of the window, ms epoch. Defaults to now",
            "in": "query",
            "name": "t",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "End of the window, ms epoch. Defaults to now",
              "title": "T"
            }
          },
          {
            "description": "Maximum number of events",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "description": "Maximum number of events",
              "maximum": 1000,
              "minimum": 1,
              "title": "Limit",
              "type": "integer"
            }
          },
          {
            "description": "API key of the account (starts with `liq_`)",
            "in": "header",
            "name": "x-api-key",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "API key of the account (starts with `liq_`)",
              "title": "X-Api-Key"
            }
          },
          {
            "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
            "in": "header",
            "name": "x-client",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
              "title": "X-Client"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "completeness": "full",
                      "exchange": "binance",
                      "price": 94231.5,
                      "qty": 0.012,
                      "side": "long",
                      "symbol": "BTC",
                      "ts": 1764640000000,
                      "vol_usd": 1130.78
                    }
                  ],
                  "meta": {
                    "count": 1,
                    "plan": "free",
                    "window": {
                      "from": 1764553600000,
                      "to": 1764640000000
                    }
                  }
                },
                "schema": {}
              }
            },
            "description": "List of events, newest first"
          },
          "401": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "invalid_key",
                    "message": "unknown API key",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `invalid_key`: unknown API key"
          },
          "403": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "plan_window",
                    "message": "free plan allows a 24h history window",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `plan_window`: free plan allows a 24h history window"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          },
          "429": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "ip_blocked",
                    "message": "too many requests with invalid keys from this address",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `ip_blocked`: too many requests with invalid keys from this address"
          }
        },
        "summary": "Liquidation events"
      }
    },
    "/api/v1/meta": {
      "get": {
        "description": "History depth (first and last stored event, approximate number of events), per-exchange totals for the last 24 hours and the limits of the current plan. `history_window_ms` is null when the plan has the full history.",
        "operationId": "get_coverage",
        "parameters": [
          {
            "description": "API key of the account (starts with `liq_`)",
            "in": "header",
            "name": "x-api-key",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "API key of the account (starts with `liq_`)",
              "title": "X-Api-Key"
            }
          },
          {
            "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
            "in": "header",
            "name": "x-client",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Kind of client, for usage stats only: `cli`, `mcp` or `ext`",
              "title": "X-Client"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "depth": {
                    "events": 20100000,
                    "from": 1699574400000,
                    "to": 1764640000000
                  },
                  "exchanges_24h": [
                    {
                      "cnt": 12034,
                      "exchange": "binance",
                      "vol": 482110050.5
                    }
                  ],
                  "limits": {
                    "history_window_ms": 86400000,
                    "rate_per_min": 5
                  },
                  "plan": "free"
                },
                "schema": {}
              }
            },
            "description": "Coverage and limits of the key's plan"
          },
          "401": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "invalid_key",
                    "message": "unknown API key",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `invalid_key`: unknown API key"
          },
          "403": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "revoked",
                    "message": "this key has been revoked",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `revoked`: this key has been revoked"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          },
          "429": {
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "error": "ip_blocked",
                    "message": "too many requests with invalid keys from this address",
                    "upgrade": "https://liquidations.dev/en/api"
                  }
                }
              }
            },
            "description": "Error code `ip_blocked`: too many requests with invalid keys from this address"
          }
        },
        "summary": "Coverage and limits"
      }
    }
  },
  "servers": [
    {
      "description": "Production",
      "url": "https://stream.liquidations.dev"
    }
  ]
}
