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

# Stellar Horizon endpoint

> Query Stellar Horizon on Chainstack Global Nodes: the REST API and server-sent event streams on the same endpoint as Stellar RPC, with JavaScript and Python SDK examples, the history window, and billing.

Stellar Global Nodes on Chainstack serve [Horizon](https://developers.stellar.org/docs/data/apis/horizon) — Stellar's REST API for accounts, ledgers, transactions, operations, payments, offers, and fee stats — on the same endpoint and auth token as [Stellar RPC](https://docs.chainstack.com/docs/stellar-tooling.md). Use Horizon for account balances, paginated payment and transaction history, and live streams of new ledgers or payments over server-sent events (SSE). Horizon is available on Mainnet and Testnet.

> [!NOTE]
>
> Horizon is available on Stellar Global Nodes starting from the [Growth plan](https://chainstack.com/pricing/). On the Developer plan, Horizon requests return `403`.

## Endpoint and authentication

The Horizon endpoint is your Stellar HTTPS endpoint — the same URL you use for Stellar RPC. To find it on Chainstack, open your node and check the **Horizon endpoint** field on the **Access and credentials** tab. See [View node access and credentials](https://docs.chainstack.com/docs/manage-your-node.md#view-node-access-and-credentials).

One URL serves both APIs, and the request decides which API answers:

| Request | Served by |
| - | - |
| `POST YOUR_CHAINSTACK_ENDPOINT` with a JSON-RPC body | Stellar RPC |
| `GET YOUR_CHAINSTACK_ENDPOINT` | Horizon root document |
| `GET YOUR_CHAINSTACK_ENDPOINT/ledgers`, `/accounts/{id}`, `/payments`, and every other Horizon path | Horizon |

Horizon builds every `_links` `href` in its responses from your endpoint URL, so the SDKs follow pagination and related-resource links without extra configuration. For every authentication option, see [Authentication methods available on Chainstack](https://docs.chainstack.com/docs/authentication-methods-for-different-scenarios.md).

A Horizon request from a node whose plan doesn't include Horizon returns `403` with the body `The Horizon API is not available on your current plan. Visit https://console.chainstack.com/user/settings/billing to upgrade.` Stellar RPC calls on the same node keep working.

## Query Horizon with cURL

Every Horizon read is an HTTP `GET` on a resource path. To fetch the latest ledger:

```bash cURL theme={"system"}
curl "YOUR_CHAINSTACK_ENDPOINT/ledgers?order=desc&limit=1"
```

The response is a HAL page: the records sit in `_embedded.records`, and `_links.next.href` points to the next page on your endpoint.

The root document — `GET YOUR_CHAINSTACK_ENDPOINT` — reports the Horizon version, the network passphrase, the latest ingested ledger in `history_latest_ledger`, and the oldest ledger Horizon holds in `history_elder_ledger`.

## JavaScript

Use the official [`@stellar/stellar-sdk`](https://github.com/stellar/js-stellar-sdk) and point `Horizon.Server` at your endpoint. `page.next()` follows the `_links.next.href` that Horizon returns.

```javascript JavaScript theme={"system"}
// npm install @stellar/stellar-sdk
import { Horizon } from "@stellar/stellar-sdk";

const server = new Horizon.Server("YOUR_CHAINSTACK_ENDPOINT");

const root = await server.root();
console.log("horizon", root.horizon_version, "| protocol", root.current_protocol_version, "| oldest ledger", root.history_elder_ledger);

const page = await server.ledgers().order("desc").limit(3).call();
for (const l of page.records) {
  console.log(`ledger ${l.sequence} closed at ${l.closed_at}, ${l.successful_transaction_count} txs`);
}

const next = await page.next();
console.log("next page starts at ledger", next.records[0].sequence);
```

```text Output theme={"system"}
horizon 30.0.1-6f7cff3903be1df4fb980a12910a1313c5d7d8dd | protocol 30 | oldest ledger 64789921
ledger 65827194 closed at 2026-12-04T22:08:25Z, 187 txs
ledger 65827193 closed at 2026-12-04T22:08:20Z, 147 txs
ledger 65827192 closed at 2026-12-04T22:08:15Z, 210 txs
next page starts at ledger 65827191
```

To read an account's sequence number and balances, call `server.loadAccount("G...")` with the account ID.

## Python

Use the official [`stellar-sdk`](https://github.com/StellarCN/py-stellar-base) and its `Server` class, which speaks the Horizon API. The `SorobanServer` class in the same package speaks Stellar RPC — see [Stellar tooling](https://docs.chainstack.com/docs/stellar-tooling.md#python).

```python Python theme={"system"}
# pip install stellar-sdk
from stellar_sdk import Server

server = Server("YOUR_CHAINSTACK_ENDPOINT")

ledgers = server.ledgers().order(desc=True).limit(3).call()
for l in ledgers["_embedded"]["records"]:
    print(f"ledger {l['sequence']} closed at {l['closed_at']}, {l['successful_transaction_count']} txs")

print("fee p50:", server.fee_stats().call()["fee_charged"]["p50"], "stroops")
```

```text Output theme={"system"}
ledger 65827198 closed at 2026-12-04T22:08:45Z, 210 txs
ledger 65827197 closed at 2026-12-04T22:08:40Z, 187 txs
ledger 65827196 closed at 2026-12-04T22:08:35Z, 144 txs
fee p50: 100 stroops
```

## Stream payments and ledgers with server-sent events

Horizon pushes new records to your application over server-sent events (SSE) on any streamable collection, such as `/payments`, `/ledgers`, `/transactions`, and `/accounts/{id}/payments`. Set the cursor to `now` to receive only records created after the stream opens. Stellar RPC has no WebSocket endpoint on Chainstack, so SSE is the way to receive live Stellar data from your node.

```javascript JavaScript theme={"system"}
import { Horizon } from "@stellar/stellar-sdk";

const server = new Horizon.Server("YOUR_CHAINSTACK_ENDPOINT");

const close = server.payments().cursor("now").stream({
  onmessage: (p) => console.log(`payment ${p.type} ${p.amount ?? ""} ${p.asset_type ?? ""}`),
  onerror: (e) => console.error("stream error", e),
});
// call close() to stop the stream
```

```python Python theme={"system"}
from stellar_sdk import Server

server = Server("YOUR_CHAINSTACK_ENDPOINT")

for p in server.payments().cursor("now").stream():
    print("payment", p["type"], p.get("amount", ""), p.get("asset_type", ""))
```

```text Output theme={"system"}
payment path_payment_strict_send 164.7445626 native
payment payment 0.9429330 native
payment payment 0.0000001 native
```

To stream with cURL, request the collection with the `Accept: text/event-stream` header:

```bash cURL theme={"system"}
curl -N -H "Accept: text/event-stream" "YOUR_CHAINSTACK_ENDPOINT/payments?cursor=now"
```

## How far back Horizon history goes

Horizon on Chainstack keeps a rolling window of about 60 days of ledgers. The root document reports the window — `history_elder_ledger` is the oldest ledger Horizon holds, and `history_latest_ledger` is the newest. Plan queries from `history_elder_ledger`, which moves forward as new ledgers close.

A request for data older than `history_elder_ledger` returns `410` with the error type `before_history`:

```json Response theme={"system"}
{
  "type": "https://stellar.org/horizon-errors/before_history",
  "title": "Data Requested Is Before Recorded History",
  "status": 410,
  "detail": "This horizon instance is configured to only track a portion of the stellar network's latest history. This request is asking for results prior to the recorded history known to this horizon instance."
}
```

The Horizon window is separate from the Stellar RPC retention window that `getHealth` reports. For full ledger history on Mainnet, use the Stellar RPC `getLedgers` method — see [Historical data availability](https://docs.chainstack.com/docs/stellar-tooling.md#historical-data-availability).

## Billing

Each Horizon request is 1 request unit (RU), the same as a Stellar RPC call. On an SSE stream, each event that Horizon sends is 1 RU. Stellar has no archive billing split, so a query near `history_elder_ledger` costs the same as one at the tip. On a node with the [Unlimited Node](https://docs.chainstack.com/docs/unlimited-node.md) add-on, Horizon requests and stream events don't consume RUs. See [Request units](https://docs.chainstack.com/docs/request-units.md).

## Next steps

* [Stellar tooling](https://docs.chainstack.com/docs/stellar-tooling.md) — Stellar RPC over JSON-RPC with cURL and the JavaScript and Python SDKs.
* [Horizon API reference](https://developers.stellar.org/docs/data/apis/horizon/api-reference) — every Horizon resource, parameter, and response field, maintained by the Stellar Development Foundation.
* [Extended nodes](https://docs.chainstack.com/docs/extended-nodes.md) — how Stellar Global Nodes keep more ledger history than a default node.
