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

# Read a data feed

> How an actor follows a stream of data or events without fetching anything itself

An actor often needs to know when something changes: a price, a piece of news, an event somewhere else. It could fetch that itself on a schedule, and pay a runner each time. A data feed is the cheaper way. Its owner keeps publishing messages to it, the network holds the recent ones, and any actor can read them.

A feed never calls your actor. The actor keeps its own place in the feed and catches up when it's asked to, so one slow reader can't hold anyone else up.

## Follow a feed

Mark a handler with `@on_stream`, and name the feed. The `guard` picks out the messages you care about, here prices above 120.00:

```python theme={"system"}
from cowboy_sdk import Actor, on_stream, watchtower

FEED = "0x<feed address>"


class Watcher(Actor):
    @on_stream(
        feed=FEED,
        guard={"field": "tags.price", "op": "gt", "value": 12000},
        numeric_tag_scales={"price": 2},
        page_limit=16,
    )
    def on_price(self, envelope_bytes: bytes) -> bytes:
        message = watchtower.wire.decode(envelope_bytes)
        self.storage["last"] = message["tags"]["price"]
        return b"ok"
```

The feed scales its numbers, so `12000` at scale 2 means 120.00.

## Catch up

Every actor with an `@on_stream` handler has a public `read_streams` handler. Each call reads one page of each feed from where the actor left off, runs your handler on the messages that match, and saves its place, all in one transaction. If your handler fails, nothing changes, and the next call tries again.

```bash theme={"system"}
cowboy actor call <actor> --handler read_streams
```

```text Output theme={"system"}
✓ Transaction submitted
→ Waiting for the receipt (up to 120s)
✓ Transaction executed in block 69436 (1.7s)
```

Anyone can make that call, and whoever calls it pays. Its result says if there's more to read. A feed keeps only its recent messages, so an actor that falls too far behind has to skip ahead.

## Find or publish a feed

The General Store lists feeds you can use. To publish your own, see [`cowboy watchtower`](https://docs.cowboy.inc/cli-specs/cowboy-watchtower).

## Next

* [An actor's schedule](https://docs.cowboy.inc/build/sdk/schedule.md)
* [Call models, the web and tools](https://docs.cowboy.inc/developers/submitting-jobs.md)


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