Horizon API vs Stellar RPC: Which One Should Your App Use?
If you are building on Stellar, you have two primary ways to interact with the network: the Horizon API and the Stellar RPC (formerly Soroban RPC). They serve different purposes, and most production applications end up using both. Here is when to use each.
What Horizon Does
Horizon is a RESTful API server that ingests the Stellar ledger and provides indexed, queryable access to historical and current blockchain data. Think of it as a read-optimized database layer on top of the raw ledger.
Horizon's Strengths
Key Horizon Endpoints
| Endpoint | Purpose |
|---|---|
| `/accounts/{id}` | Account balances, signers, thresholds |
| `/transactions` | Transaction history with filtering |
| `/operations` | Operation details across all types |
| `/payments` | Payment-specific operations |
| `/assets` | Asset listing with holder counts |
| `/order_book` | Current order book for any pair |
| `/trade_aggregations` | OHLCV candle data |
| `/fee_stats` | Current network fee statistics |
| `/ledgers` | Ledger history with metadata |
When to Use Horizon
What Stellar RPC Does
Stellar RPC is a JSON-RPC interface for interacting with the network's current state and smart contracts. It was originally called Soroban RPC and now serves as the unified real-time interface.
RPC's Strengths
Key RPC Methods
| Method | Purpose |
|---|---|
| `getLatestLedger` | Current ledger sequence and protocol version |
| `simulateTransaction` | Dry-run a transaction, get resource estimates |
| `sendTransaction` | Submit a signed transaction |
| `getTransaction` | Check transaction status by hash |
| `getEvents` | Query contract events with filters |
| `getLedgerEntries` | Read specific ledger entries |
When to Use RPC
Side-by-Side Comparison
| Capability | Horizon | Stellar RPC |
|---|---|---|
| **Protocol** | REST (HTTP) | JSON-RPC |
| **Historical data** | Yes (full history) | No (recent only) |
| **Transaction submission** | Yes (basic) | Yes (with simulation) |
| **Smart contract storage** | No | Yes |
| **Contract events** | No | Yes |
| **Transaction simulation** | No | Yes |
| **Order book** | Yes | No |
| **Trade aggregations** | Yes | No |
| **Asset listing** | Yes | No |
Using Both Together
Most production applications use both:
Example: Building a token dashboard — use Horizon for asset info, holder counts, payment history. Use RPC for reading DeFi contract state and monitoring events.
Infrastructure Considerations
Running your own Horizon instance requires PostgreSQL, Captive Core, disk management, and 24/7 monitoring. Running RPC is simpler but still needs infrastructure. Managed services like LumenQuery handle all of this:
*Build on both APIs without running a single node. LumenQuery provides managed Horizon and Soroban RPC with sub-100ms response times. Start free.*