> For the complete documentation index, see [llms.txt](https://docs.espressosys.com/network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.espressosys.com/network/developer/espresso-api/events-api.md).

# Events API

This API allows a client, not participating in consensus, to follow along with consensus in a trustless manner, by streaming and verifying events produced by consensus. It is especially useful for block builders, who need to maintain their own view of the internal consensus state at all times, so that they can intelligently propose blocks on top of not-yet-finalized proposed parent blocks.

{% hint style="warning" %}
This API is often served on a different port than other APIs, for reasons that will be resolved in future releases.
{% endhint %}

## Types

### `LeafInfo`

The specific format of this type is not currently specified, but it can be deserialized and interpreted in Rust using the [`LeafInfo`](https://hotshot.docs.espressosys.com/hotshot_types/event/struct.LeafInfo.html) type.

### `DAProposal`

The specific format of this type is not currently specified, but it can be deserialized and interpreted in Rust using the [`Proposal`](https://hotshot.docs.espressosys.com/hotshot_types/message/struct.Proposal.html) type.

### `QuorumProposal`

The specific format of this type is not currently specified, but it can be deserialized and interpreted in Rust using the [`Proposal`](https://hotshot.docs.espressosys.com/hotshot_types/message/struct.Proposal.html) type.

## Endpoints

### GET `/hotshot-events/events`

{% hint style="info" %}
This is a WebSockets endpoint. The client must be prepared to upgrade the connection to a WebSockets connection, including the proper headers.
{% endhint %}

Subscribe to consensus events.

#### Yields

```json
{
    "view_number": integer,
    "event":
        {
            "StartupInfo": {
                "known_node_with_stake": [
                    {
                    }
                ]
            }
        }
      | { "HotshotError": { "error": ... } }
      | { "HotshotTransactions": { "transactions": [Transaction] } }
      | {
            "HotshotDecide": {
                "leaf_chain": [LeafInfo],
                "block_size": null | integer
            }
        }
      | {
            "HotshotDAProposal": {
                "proposal": DAProposal,
                "sender": tagged<BLS_VER_KEY>
            }
        }
      | {
            "HotshotQuorumProposal": {
                "proposal": QuorumProposal,
                "sender": tagged<BLS_VER_KEY>
            }
        }
      | "Unknown"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.espressosys.com/network/developer/espresso-api/events-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
