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:

  • 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>.ResponseEnum

    Parameters

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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>.ResponseEnum

    Parameters

    accountId

    The Stellar account ID to get operations for

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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>.ResponseEnum

    Parameters

    claimableBalanceId

    The claimable balance ID (B-address or hex format)

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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>.ResponseEnum

    Parameters

    ledger

    The ledger sequence number

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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>.ResponseEnum

    Parameters

    hash

    The transaction hash (hex-encoded)

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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>.ResponseEnum

    Parameters

    liquidityPoolId

    The liquidity pool ID (L-address or hex format)

    cursor

    Optional paging token, specifying where to start returning records from

    order

    Optional sort order - .ascending or .descending

    limit

    Optional maximum number of records to return. Default: 10, max: 200

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. Set to “transactions” to include transaction data in response

    Return Value

    PageResponse containing operations for the liquidity pool or error

  • 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 -> OperationDetailsResponseEnum

    Parameters

    operationId

    The operation ID

    includeFailed

    Optional. Set to true to include failed operations

    join

    Optional. 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) -> OperationsStreamItem

    Parameters

    transactionsType

    The filter specifying which operations to stream (all, by account, ledger, transaction, claimable balance, or liquidity pool)

    Return Value

    OperationsStreamItem for receiving streaming operation updates

  • 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>.ResponseEnum

    Parameters

    url

    The complete URL to fetch operations from

    Return Value

    PageResponse containing operations or error