> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bloklake.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sampling blocks

> Time series over long ranges with blockInterval: base fee every hour, gas used every day.

To chart a block-level metric over months, you don't need every block. `blockInterval` returns
every n-th block. With the [Python client](https://docs.bloklake.com/clients.md):

```python theme={null}
from bloklake import Bloklake

bl = Bloklake(chain="eth")

# Ethereum: 300 blocks ≈ 1 hour (12 s blocks)
page = bl.collect({
    "from_block": 19426000,
    "to_block": 19427499,
    "block_interval": 300,
    "fields": {"block": ["number", "timestamp", "base_fee_per_gas", "gas_used"]},
})
for b in page.blocks:
    print(b["number"], b["timestamp"], int(b["base_fee_per_gas"]) / 1e9, "gwei", b["gas_used"])
```

```text theme={null}
19426200 1710333467 66.415974755 gwei 15033090
19426500 1710337091 71.351142843 gwei 14971784
19426800 1710340715 53.076298262 gwei 29999024
19427100 1710344423 72.584137839 gwei 6740880
19427400 1710348107 74.480257029 gwei 16078401
```

Blocks whose number is a multiple of 300 (`blockOffset` defaults to 0). Use `blockOffset` to
shift the phase: `"blockInterval": 300, "blockOffset": 150` returns 19426150, 19426450, ….

## Intervals for common periods

| Period | Ethereum (12 s) | Robinhood Chain (\~100 ms) |
| - | - | - |
| 1 minute | 5 | 600 |
| 1 hour | 300 | 36,000 |
| 1 day | 7,200 | 864,000 |

Block times aren't perfectly regular, so these give approximately evenly spaced samples. Use
`timestamp` for the x-axis, not the block number.

## Cost

One year of Ethereum is about 2.6 million blocks. Hourly samples are about 8,760 rows; with the
four fields above (about 40 bytes per row), that's 350 KB. A year of hourly base fees costs
almost nothing.

The range still pages at 50,000 blocks, so a year is about 53 requests. Use the
[pagination loop](https://docs.bloklake.com/querying/pagination.md).

## Rules

* `blockInterval` applies only to the blocks stream. It needs block fields selected.
* Logs and transactions in the same request are **not** sampled.
* With a `logs` or `transactions` filter, the blocks stream already holds only blocks with a
  match; sampling applies on top of that.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.