> For the complete documentation index, see [llms.txt](https://docs.hatchr.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hatchr.fun/developers/realtime-updates.md).

# Realtime Updates

Hatchr uses a dedicated WebSocket service for confirmed token updates. REST supplies initial state and periodic reconciliation; SSE is the automatic fallback.

## Connect

Production clients connect to the configured secure endpoint:

```
wss://<realtime-domain>/realtime
```

The server validates the request origin and limits messages to 16 KB.

## Subscribe

```json
{
  "type": "subscribe",
  "token": "0x..."
}
```

The service responds with `subscribed` and a `token.update` snapshot when available.

## Update message

```json
{
  "type": "token.update",
  "sequence": 12,
  "token": { "address": "0x...", "symbol": "TOKEN" },
  "latestTrade": null,
  "holders": [],
  "reason": "chain",
  "sourceBlock": "7800000",
  "timestamp": "2026-07-13T20:00:00.000Z"
}
```

The full token object contains current indexed identity, market, pool, fee and graduation fields.

## Unsubscribe

```json
{
  "type": "unsubscribe",
  "token": "0x..."
}
```

## Delivery behavior

* Updates are broadcast only to clients subscribed to the affected token.
* A monotonically increasing token sequence helps clients reject stale messages.
* Ping/pong heartbeats detect dead connections.
* Browser clients reconnect with exponential backoff.
* SSE activates when WebSocket is unavailable.
* Periodic REST reconciliation repairs missed state.

{% hint style="info" %}
Realtime delivery begins only after the indexer commits confirmed state to PostgreSQL. It is not a mempool feed.
{% endhint %}


---

# 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.hatchr.fun/developers/realtime-updates.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.
