Expand description
Stellar Horizon SDK for Rust
This Rust library provides a user-friendly interface to the Stellar Horizon API,
allowing developers to easily query and transact on the Stellar network. Centered
around the HorizonClient, the SDK abstracts the underlying HTTP request and response
mechanisms into a set of simple, high-level methods.
The SDK is designed with a focus on developer experience, providing clear abstractions, sensible defaults, and streamlined error handling.
§Status
The SDK is under active development. It is functional but should be considered a work-in-progress. Features may be added or changed, and the SDK may evolve before stabilization.
§Supported endpoints:
- Accounts
- Assets
- Claimable balance
- Effects
- Fee stats
- Ledgers
- Liquidity pools
- Operations
- Offers
- Orderbook
- Paths
- Payments
- Trades
- Trade aggregations
- Transactions
§Example Usage
The following example demonstrates how to use the HorizonClient to retrieve a list
of accounts with a specific signer:
use stellar_rs::horizon_client::HorizonClient;
use stellar_rs::accounts::prelude::{AccountsRequest, AccountsResponse};
use stellar_rs::models::{Request, Response};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the Horizon client with the testnet server
let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org")?;
// Create a request to fetch accounts with a specific signer
let accounts_request = AccountsRequest::new()
.set_signer_filter("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7")?
.set_limit(10)?;
// Perform the request using the Horizon client
let accounts_response =
horizon_client.get_account_list(&accounts_request)
.await;
// Check for success and handle the response or error
match accounts_response {
Ok(response) => {
// Process the response
},
Err(e) => {
// Handle the error
}
}
Ok(())
}This example initializes a HorizonClient, constructs an AccountsRequest to filter
accounts by signer, and calls get_account_list to retrieve the relevant data.
The result is then handled in a match expression, demonstrating the SDK’s straightforward
error handling.
Visit the documentation for HorizonClient and endpoint-specific request and response
types for more examples and detailed usage instructions.
Modules§
- accounts
- Provides
RequestandResponsestructs for retrieving accounts. - assets
- Provides
RequestandResponsestructs for retrieving assets. - claimable_
balances - Provides
RequestandResponsestructs for retrieving claimable balances. - effects
- Provides
RequestandResponsestructs for retrieving effects. - fee_
stats - Provides
RequestandResponsestructs for retrieving fee stats. - horizon_
client - Client for calling the Stellar Horizon API
- ledgers
- Provides
RequestandResponsestructs for retrieving ledgers. - liquidity_
pools - Provides
RequestandResponsestructs for retrieving liquidity pools. - models
- Contains core data structures and traits.
- offers
- Provides
RequestandResponsestructs for retrieving offers. - operations
- Provides
RequestandResponsestructs for retrieving operations. - order_
book - Provides
RequestandResponsestructs for retrieving order book details. - paths
- Provides
RequestandResponsestructs for retrieving payment paths. - payments
- Provides
RequestandResponsestructs for retrieving payments. - trade_
aggregations - Provides
RequestandResponsestructs for retrieving trade aggregation details. - trades
- Provides
RequestandResponsestructs for retrieving trades. - transactions
- Provides
RequestandResponsestructs for retrieving transactions.