---
sidebar:
  hidden: true
title: roboto.formats.mcap.fetch
---
## Module Contents

### open_for_window()

```python
def roboto.formats.mcap.fetch.open_for_window(
    signed_url: str,
    start_time: Optional[int] = None,
    end_time: Optional[int] = None,
    topic_name: Optional[str] = None,
) -> roboto.storage.HttpRangeReader
```

`from roboto.formats.mcap import open_for_window`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/fetch.py#L16-L88)

Open an MCAP file at a URL for reading, prefetching only the chunks in a log-time window and on one topic.

[`get_data()`](/docs/reference/python-sdk/roboto/domain/topics/topic#roboto.domain.topics.topic.Topic.get_data) opens MCAP files through it, so most code never calls it.

Reads the file's summary section, then prefetches in parallel each chunk whose log-time range, as its chunk index records it, overlaps `[start_time, end_time)` and, given a `topic_name`, whose chunk index lists a message index for a channel on that topic. Later reads of those chunks make no request. A file with no summary section or no chunk index opens with no chunk prefetched.

Given a `topic_name`, a chunk whose index lists no message indexes is not prefetched, since the index does not show which topics the chunk holds; its bytes are downloaded when it is read.

Chunks are selected by log time only. To select messages by another timestamp, pass no bounds, which prefetches every chunk, and filter the messages after decoding them.

**Parameters**

- **signed_url** (`str`): URL of the MCAP file, such as a signed download URL. The server must answer HTTP `Range` requests.
- **start_time** (`Optional[int]`): Inclusive start of the window, in nanoseconds of message log time. `None` leaves the window open at the start.
- **end_time** (`Optional[int]`): Exclusive end of the window, in the same form. `None` leaves the window open at the end.
- **topic_name** (`Optional[str]`): Topic whose chunks to prefetch. `None` prefetches the chunks of every topic.

**Returns**

- `roboto.storage.HttpRangeReader`: [`HttpRangeReader`](/docs/reference/python-sdk/roboto/storage/http_range_reader#roboto.storage.http_range_reader.HttpRangeReader) over the file, positioned at its first byte, with the selected chunks already downloaded. You own the returned reader: close it with [`close()`](/docs/reference/python-sdk/roboto/storage/http_range_reader#roboto.storage.http_range_reader.HttpRangeReader.close), or use it as a context manager.

**Raises**

- `OSError`: A response has an HTTP error status or holds bytes other than the ones requested, or the server sends no `Content-Range` header with the file's size.
- `urllib3.exceptions.MaxRetryError`: A request still fails with a network error after 3 retries.
- `mcap.exceptions.McapError`: The file does not end with an MCAP footer, or its summary section cannot be read.
