OperationsService
public class OperationsService : @unchecked Sendable
Service for querying operation history from the Stellar Horizon API.
The OperationsService provides methods to retrieve operations (individual actions within transactions) filtered by account, ledger, transaction, claimable balance, or liquidity pool. Supports pagination and streaming of real-time operation updates.
Example usage:
let sdk = StellarSDK()
// Get operations for an account
let response = await sdk.operations.getOperations(
forAccount: "GACCOUNT...",
limit: 20,
order: .descending
)
switch response {
case .success(let page):
for operation in page.records {
print("Type: \(operation.operationType)")
}
case .failure(let error):
print("Error: \(error)")
}
See also:
- Stellar developer docs
- OperationResponse for operation data structures
-
getOperations(from:Asynchronousorder: limit: includeFailed: join: ) Retrieves all operations from Horizon API with pagination support.
Declaration
Swift
open func getOperations(from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations or error
-
Retrieves operations for a specific account with pagination support.
Declaration
Swift
open func getOperations(forAccount accountId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
accountIdThe Stellar account ID to get operations for
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations for the account or error
-
Retrieves operations for a specific claimable balance with pagination support.
Supports both encoded (B-prefixed) and hex claimable balance IDs.
Declaration
Swift
open func getOperations(forClaimableBalance claimableBalanceId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
claimableBalanceIdThe claimable balance ID (B-address or hex format)
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations for the claimable balance or error
-
Retrieves operations for a specific ledger with pagination support.
Declaration
Swift
open func getOperations(forLedger ledger: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
ledgerThe ledger sequence number
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations for the ledger or error
-
Retrieves operations for a specific transaction with pagination support.
Declaration
Swift
open func getOperations(forTransaction hash: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
hashThe transaction hash (hex-encoded)
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations for the transaction or error
-
Retrieves operations for a specific liquidity pool with pagination support.
Supports both encoded (L-prefixed) and hex liquidity pool IDs.
Declaration
Swift
open func getOperations(forLiquidityPool liquidityPoolId: String, from cursor: String? = nil, order: Order? = nil, limit: Int? = nil, includeFailed: Bool? = nil, join: String? = nil) async -> PageResponse<OperationResponse>.ResponseEnumParameters
liquidityPoolIdThe liquidity pool ID (L-address or hex format)
cursorOptional paging token, specifying where to start returning records from
orderOptional sort order - .ascending or .descending
limitOptional maximum number of records to return. Default: 10, max: 200
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
PageResponse containing operations for the liquidity pool or error
-
getOperationDetails(operationId:AsynchronousincludeFailed: join: ) Retrieves detailed information for a specific operation by ID.
Returns operation details including type-specific data.
Declaration
Swift
open func getOperationDetails(operationId: String, includeFailed: Bool? = nil, join: String? = nil) async -> OperationDetailsResponseEnumParameters
operationIdThe operation ID
includeFailedOptional. Set to true to include failed operations
joinOptional. Set to “transactions” to include transaction data in response
Return Value
OperationDetailsResponseEnum with operation details or error
-
Streams real-time operation updates via Server-Sent Events from Horizon.
Declaration
Swift
open func stream(for transactionsType: OperationsChange) -> OperationsStreamItemParameters
transactionsTypeThe filter specifying which operations to stream (all, by account, ledger, transaction, claimable balance, or liquidity pool)
Return Value
OperationsStreamItem for receiving streaming operation updates
-
getOperationsFromUrl(url:Asynchronous) Retrieves operations from a complete URL.
Useful for pagination navigation with next/prev links from PageResponse.
Declaration
Swift
open func getOperationsFromUrl(url: String) async -> PageResponse<OperationResponse>.ResponseEnumParameters
urlThe complete URL to fetch operations from
Return Value
PageResponse containing operations or error
View on GitHub
Install in Dash