# Examples

Runnable scripts and notebooks for `lightning-client`. Install the package
from the release ZIP first — see the top-level [README](../README.md#install).

## Scripts

Run any of the following from the unpacked release-ZIP directory:

```bash
python examples/quickstart.py
python examples/catalog.py
python examples/trend.py
python examples/uns.py
python examples/stream.py
python examples/poll.py
```

Each script targets `127.0.0.1:9100` by default; set `LIGHTNING_ENDPOINT`
to override.

## Notebook: `query.ipynb`

One cell drives a live latency monitor using `ipympl` + `FuncAnimation`.
Each tick calls `w.data(since=cursor)` and plots server `query_us` in µs
over a rolling 5-minute window. **Stop** with the kernel interrupt or by
closing the figure.

The notebook needs the `notebook` extra (it installs `jupyterlab`,
`ipympl`, `matplotlib`, `numpy`, and `pandas`):

```bash
pip install --find-links . "lightning-client[notebook]"
jupyter lab examples/query.ipynb
```

Or with classic notebook:

```bash
jupyter notebook examples/query.ipynb
```

**Restart the kernel** after installing the `notebook` extra so the
`widget` backend registered by `ipympl` is picked up.

### Environment variables

| Var                                      | Default          | Notes                                                   |
| ---------------------------------------- | ---------------- | ------------------------------------------------------- |
| `LIGHTNING_ENDPOINT`                     | `127.0.0.1:9100` | `host:port` of the Lightning server. Lightning listens on port `9100` — replace `127.0.0.1` with the IP or hostname of the machine running Lightning if it is not on this machine. |
| `LIGHTNING_NAMESPACE`, `LIGHTNING_WINDOW` | auto-pick        | Pin a specific namespace / window label.                |
| `BENCH_WINDOW_SEC`                       | `300`            | Rolling time window in seconds.                         |
| `BENCH_POLL_SEC`                         | `1.0`            | Seconds between incremental `data(since=...)` calls.    |
| `BENCH_ANIM_MS`                          | `200`            | Animation refresh interval (ms).                        |
