> For the complete documentation index, see [llms.txt](https://hydromancer.xyz/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hydromancer.xyz/docs/rest-api/historical-data/liquidationbuckets.md). Agents can also search and read this documentation through its [MCP server](https://hydromancer.xyz/docs/~gitbook/mcp).

# liquidationBuckets

Get grouped long and short liquidation totals in up to 200 UTC periods.

Returns historical liquidation totals for one perpetual market, including HIP-3. Send an authenticated `POST /info` using your normal bearer API key.

| Field         | Type    | Meaning                                                                                       |
| ------------- | ------- | --------------------------------------------------------------------------------------------- |
| `type`        | string  | `"liquidationBuckets"`                                                                        |
| `coin`        | string  | Required, case-sensitive: e.g. `"BTC"` or `"xyz:NVDA"`. Spot/outcome markets are unsupported. |
| `granularity` | string  | Required: `1m`, `5m`, `15m`, `30m`, `1h`, `4h`, `1d`.                                         |
| `startTime`   | integer | Optional Unix milliseconds selecting the first containing bucket.                             |
| `endTime`     | integer | Optional Unix milliseconds selecting the last containing bucket, inclusive.                   |

| Supplied times | Selection                                               |
| -------------- | ------------------------------------------------------- |
| Neither        | Most recent 200 periods, including the current period.  |
| End only       | 200 periods ending in the end timestamp's bucket.       |
| Start only     | 200 periods commencing in the start timestamp's bucket. |
| Both           | Start through end buckets, capped at the first 200.     |

Times must be nonnegative JSON integers in **milliseconds**; there is no seconds conversion. Null, strings, floats, booleans and reversed ranges are invalid. Inputs and the complete derived query window must fit `1970-01-01T00:00:00.000Z` through `2299-12-31T23:59:59.999Z`. A derived start before the Unix epoch is clamped to zero.

Buckets align to UTC and include **whole periods**. At `5m`, start 12:03 and end 12:11 select 12:00, 12:05 and 12:10, covering `[12:00, 12:15)`. End exactly at 12:10 includes that whole bucket.

```json
{
  "type": "liquidationBuckets",
  "coin": "BTC",
  "granularity": "1m",
  "startTime": 1767225600000,
  "endTime": 1767225660000
}
```

## Response

An oldest-first array with these fields per bucket:

| Field                         | Type    | Meaning                                           |
| ----------------------------- | ------- | ------------------------------------------------- |
| `ts`                          | integer | UTC bucket start in Unix milliseconds.            |
| `longLiquidationNotionalUsd`  | string  | Exact USD notional of forced sells closing longs. |
| `shortLiquidationNotionalUsd` | string  | Exact USD notional of forced buys closing shorts. |
| `longLiquidationCount`        | integer | Grouped long liquidation executions.              |
| `shortLiquidationCount`       | integer | Grouped short liquidation executions.             |

Counts group fills by liquidated user, original millisecond timestamp and order ID within the market. Four fills of one execution count once; all four contribute notional. Counts are not distinct accounts or entire multi-order liquidation cycles. Market and backstop liquidations are included; notionals have up to 20 fractional places.

**Quiet periods remain in the response**, with `"0"` notionals and zero counts. A 200-period query returns all 200 rows even when the market has no liquidations. Only a shorter explicit range or the Unix-epoch boundary reduces the row count. Unknown perpetual names also return zeros; names are not uppercased or aliased.

The current bucket is incomplete, and historical writes can arrive late. Zeros mean no matching stored rows, not proof of complete ingestion. Read failures return an error; they never become successful empty or zero-filled fallback data.

Continue with `startTime = last_ts + period_ms`, retaining the original end for a bounded range. Stop once the next start exceeds the desired final bucket. No cursor, caller-controlled bucket limit, page number or `interval` alias is used.

## Python SDK

```python
from hydromancer_sdk import RestClient

client = RestClient(api_key="YOUR_API_KEY")
buckets = await client.liquidation_buckets(
    "BTC", "1m", start_time=1767225600000, end_time=1767225660000
)
```

Returns `list[LiquidationBucket]`. Generic `call("liquidationBuckets", ...)` is also typed; `call_structured(...)` additionally retains response headers/evidence.

## Errors and cost

This method defaults to `structured-v1` after authentication/method identification. Errors contain `error`, `code` and `correlationId`: invalid inputs return `400 invalid_request`, history/resource failures `503 unavailable`, and internal failures `500 internal`. Existing auth/rate limits apply; selector-free auth rejection retains the normal legacy 401. Admission costs **five points**.
