> ## 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.

# Blocks

> When block rows come back, and how to sample them.

Blocks can't be filtered (beyond the range). Whether you get them depends on what else you ask
for.

## Every block in a range

Select block fields and send no `logs` or `transactions` filter:

```json theme={null}
{
  "fromBlock": 19426000,
  "toBlock": 19426099,
  "fields": {"block": {"number": true, "timestamp": true, "baseFeePerGas": true, "gasUsed": true}}
}
```

100 rows, one per block.

## Only blocks that contain a match

Select block fields **and** filter logs or transactions. The blocks stream then holds only the
blocks with at least one matched log or matched transaction (the union of both):

```json theme={null}
{
  "fromBlock": 19426000,
  "toBlock": 19426099,
  "logs": [{"address": ["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"]}],
  "fields": {
    "log": {"blockNumber": true, "logIndex": true, "data": true},
    "block": {"number": true, "timestamp": true}
  }
}
```

This is the cheapest way to get timestamps for your matches when you need more than the log's
own `blockTimestamp`: one block row per block with a match, not one per log.

> [!TIP]
>
> If all you need is the timestamp of each log, select `blockTimestamp` on the log instead of
> requesting a blocks stream.

## Sampling: every n-th block

`blockInterval` keeps only the blocks whose number is `≡ blockOffset (mod blockInterval)`:

```json theme={null}
{
  "fromBlock": 19426000,
  "toBlock": 19426099,
  "blockInterval": 25,
  "blockOffset": 3,
  "fields": {"block": {"number": true, "baseFeePerGas": true}}
}
```

Returns blocks 19426003, 19426028, 19426053 and 19426078.

* It applies only to the blocks stream, after the rules above. Logs and transactions are not
  sampled.
* It needs block fields selected (`400` otherwise).
* `blockOffset` must be smaller than `blockInterval`.

See [Sampling blocks](https://docs.bloklake.com/guides/sampling-blocks.md) for time series like "base fee every hour".


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