# userTwapSummaries - User TWAP Summaries

Use `userTwapSummaries` to retrieve recent execution-derived TWAP summaries for one Hyperliquid user address. Each summary aggregates indexed TWAP slice fills by `(user, twapId)`.

TWAP summaries are derived from executed slice fills in the Hyperliquid Index. They summarize observed executions, not the full parent TWAP order intent or configuration.

## Endpoints

REST-style Info API:

```text
POST https://api-hyperliquid-index.n.dwellir.com/YOUR_API_KEY/info
```

JSON-RPC:

```text
POST https://api-hyperliquid-index.n.dwellir.com/YOUR_API_KEY/jsonrpc
```

## Billing

`userTwapSummaries` responses are billed by the number of TWAP summary objects returned, not as one response per HTTP request.
A response with `50` summaries counts as `50` responses/API credits.

Requests that return an empty array are billed as `0` responses/API credits and do not count against usage. Error responses are not charged.

## Request Parameters

- `type` (`string, required`): Must be userTwapSummaries for /info REST requests. Omit this field for JSON-RPC.
- `user` (`string, required`): 0x-prefixed Hyperliquid user address.
- `coin` (`string, optional`): Exact Hyperliquid market symbol, for example BTC. When supplied, only rows for that market are returned.
- `limit` (`number, optional`): Maximum summaries to return, capped at 500.

## Request Example

```bash
curl -X POST "https://api-hyperliquid-index.n.dwellir.com/YOUR_API_KEY/info" \
  -H "content-type: application/json" \
  -d '{
  "type": "userTwapSummaries",
  "user": "0x1111111111111111111111111111111111111111",
  "coin": "BTC",
  "limit": 100
}'
```

## Response Fields

- `summaries` (`array, required`): Array of execution-derived TWAP summary objects. /info returns this array directly; JSON-RPC returns it under result. Empty matches return an empty array and are billed as 0 responses/API credits. Billing counts one response/API credit per summary object returned.
- `user` (`string, required`): User address.
- `twapId` (`number, required`): TWAP order ID.
- `coin` (`string, required`): Hyperliquid market symbol.
- `side` (`string, required`): B for bid/buy side, A for ask/sell side.
- `avgPx` (`string, required`): Size-weighted average execution price as a decimal string.
- `sz` (`string, required`): Total executed size across indexed slices as a decimal string.
- `fee` (`string, required`): Total user fee across indexed slices as a decimal string.
- `closedPnl` (`string, required`): Total realized PnL across indexed slices as a decimal string.
- `nSlices` (`number, required`): Number of slice fill rows included in the summary.
- `firstFillTime` (`number, required`): Earliest slice fill timestamp in Unix milliseconds.
- `lastFillTime` (`number, required`): Latest slice fill timestamp in Unix milliseconds.
- `txIndex` (`number, optional`): Block-local fill event index for the latest slice in the summary.

## Successful Response

```json
[
  {
    "user": "0x1111111111111111111111111111111111111111",
    "twapId": 1755601,
    "coin": "BTC",
    "side": "B",
    "avgPx": "100.5",
    "sz": "0.25",
    "fee": "0.01",
    "closedPnl": "0",
    "nSlices": 2,
    "firstFillTime": 1753606200000,
    "lastFillTime": 1753606260000,
    "txIndex": 8
  }
]
```

## Error Responses

### Error

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32602,
    "message": "invalid request"
  }
}
```

## REST-style Example

```bash
curl -X POST "https://api-hyperliquid-index.n.dwellir.com/YOUR_API_KEY/info" \
  -H "content-type: application/json" \
  -d '{
  "type": "userTwapSummaries",
  "user": "0x1111111111111111111111111111111111111111",
  "coin": "BTC",
  "limit": 50
}'
```

## JSON-RPC Example

```bash
curl -X POST "https://api-hyperliquid-index.n.dwellir.com/YOUR_API_KEY/jsonrpc" \
  -H "content-type: application/json" \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "userTwapSummaries",
  "params": {
    "user": "0x1111111111111111111111111111111111111111",
    "coin": "BTC",
    "limit": 50
  }
}'
```

## Response

REST `/info` responses return an array directly. JSON-RPC responses return the same array under `result`. Empty matches return `[]`; they are not errors.

Results are ordered newest first by `lastFillTime`, then `txIndex`, then `twapId`.
