# ListEvents - Stream Historical Sui Events

`LedgerService.ListEvents` streams matching Move events from the indexed ledger. Each event carries its checkpoint, transaction digest, transaction index, and event index when requested.

## Method Signature

- **Service:** `sui.rpc.v2.LedgerService`
- **Method:** `ListEvents`
- **Type:** Server-streaming RPC

## Request Parameters

- `read_mask` (`FieldMask, optional`): Fields of Event to return. Use paths relative to that message.
- `start_checkpoint` (`uint64, optional`): Inclusive checkpoint lower bound. Omit to start at the earliest retained checkpoint.
- `end_checkpoint` (`uint64, optional`): Exclusive checkpoint upper bound. Omit to scan up to the indexed tip.
- `filter` (`EventFilter, optional`): Optional server-side filter. An included filter must contain at least one term.
- `options` (`QueryOptions, optional`): Scan limit, cursor bounds, and ordering. Use options.after for ascending continuation.

## Request Example

```bash
grpcurl \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
  "start_checkpoint": "RECENT_CHECKPOINT",
  "options": {
    "limit": 2
  },
  "read_mask": {
    "paths": [
      "checkpoint",
      "transaction_digest",
      "event_index",
      "event_type"
    ]
  }
}' \
  api-sui-mainnet-full.n.dwellir.com:443 \
  sui.rpc.v2.LedgerService/ListEvents
```

## Response Fields

- `event` (`Event, optional`): Requested event.
- `watermark` (`Watermark, optional`): Progress and continuation cursor. Present even when a frame contains no matching item.
- `end` (`QueryEnd, optional`): Scan end reason on the final successful frame.

## Successful Response

```protobuf
message ListEventsResponse {
  optional Event event = 1;
  optional Watermark watermark = 2;
  optional QueryEnd end = 3;
}
```

## Error Responses

### Range outside retained history

- Code: `OUT_OF_RANGE`
- Description: The lower bound predates retained history. Check GetServiceInfo and use an archival source for older data.

Use `event_type` to identify the declared event type. `package_id` and `module` identify the top-level Move call that triggered emission and can differ from the event type's package and module.

## Related Methods

- [ListTransactions](https://www.dwellir.com/docs/sui/grpc/ledger/list-transactions)
- [SubscribeEvents](https://www.dwellir.com/docs/sui/grpc/subscription/subscribe-events)

See the [official Sui gRPC schema](https://github.com/MystenLabs/sui-apis/blob/main/proto/sui/rpc/v2/ledger_service.proto) for the current protobuf definition.

## Retention and filters

Replace `RECENT_CHECKPOINT` with a recent `checkpointHeight` from [GetServiceInfo](https://www.dwellir.com/docs/sui/grpc/ledger/get-service-info). A lower bound before retained history returns `OUT_OF_RANGE`.

See [filter syntax and examples](https://www.dwellir.com/docs/sui/grpc-overview#server-side-filters) before adding a `filter`. An included filter must contain at least one term.

For recovery and deduplication, include both `transaction_digest` and `event_index` in the subscription and replay masks. Different events from one transaction share its digest.
