pub struct IndexerClient { /* private fields */ }indexer only.Expand description
Client for the Aptos indexer GraphQL API.
The indexer provides access to indexed blockchain data including tokens, events, and transaction history. Queries are automatically retried with exponential backoff for transient failures.
§Example
use aptos_sdk::api::IndexerClient;
use aptos_sdk::config::AptosConfig;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = AptosConfig::testnet();
let client = IndexerClient::new(&config)?;
// Use the client for GraphQL queries
Ok(())
}Implementations§
Source§impl IndexerClient
impl IndexerClient
Sourcepub fn new(config: &AptosConfig) -> AptosResult<Self>
pub fn new(config: &AptosConfig) -> AptosResult<Self>
Creates a new indexer client.
§TLS Security
This client uses reqwest with its default TLS configuration, which
validates server certificates against the system’s certificate store.
All Aptos indexer endpoints use HTTPS with valid certificates.
§Errors
Returns an error if the indexer URL is not configured in the config, or if the HTTP client fails to build (e.g., invalid TLS configuration).
Sourcepub fn with_url(url: &str) -> AptosResult<Self>
pub fn with_url(url: &str) -> AptosResult<Self>
Sourcepub async fn query<T: for<'de> Deserialize<'de> + Send + 'static>(
&self,
query: &str,
variables: Option<Value>,
) -> AptosResult<T>
pub async fn query<T: for<'de> Deserialize<'de> + Send + 'static>( &self, query: &str, variables: Option<Value>, ) -> AptosResult<T>
Executes a GraphQL query.
§Errors
Returns an error if the HTTP request fails, the API returns an error status code, the response cannot be parsed as JSON, the GraphQL query contains errors, or the response data is missing.
Sourcepub async fn get_fungible_asset_balances(
&self,
address: AccountAddress,
) -> AptosResult<Vec<FungibleAssetBalance>>
pub async fn get_fungible_asset_balances( &self, address: AccountAddress, ) -> AptosResult<Vec<FungibleAssetBalance>>
Sourcepub async fn get_account_tokens(
&self,
address: AccountAddress,
) -> AptosResult<Vec<TokenBalance>>
pub async fn get_account_tokens( &self, address: AccountAddress, ) -> AptosResult<Vec<TokenBalance>>
Sourcepub async fn get_account_transactions(
&self,
address: AccountAddress,
limit: Option<u32>,
) -> AptosResult<Vec<Transaction>>
pub async fn get_account_transactions( &self, address: AccountAddress, limit: Option<u32>, ) -> AptosResult<Vec<Transaction>>
Source§impl IndexerClient
impl IndexerClient
Sourcepub async fn get_account_tokens_paginated(
&self,
address: AccountAddress,
pagination: Option<PaginationParams>,
) -> AptosResult<Page<TokenBalance>>
pub async fn get_account_tokens_paginated( &self, address: AccountAddress, pagination: Option<PaginationParams>, ) -> AptosResult<Page<TokenBalance>>
Sourcepub async fn get_account_transactions_paginated(
&self,
address: AccountAddress,
pagination: Option<PaginationParams>,
) -> AptosResult<Page<Transaction>>
pub async fn get_account_transactions_paginated( &self, address: AccountAddress, pagination: Option<PaginationParams>, ) -> AptosResult<Page<Transaction>>
Sourcepub async fn get_events_by_type(
&self,
event_type: &str,
limit: Option<u32>,
) -> AptosResult<Vec<Event>>
pub async fn get_events_by_type( &self, event_type: &str, limit: Option<u32>, ) -> AptosResult<Vec<Event>>
Sourcepub async fn get_events_by_account(
&self,
address: AccountAddress,
limit: Option<u32>,
) -> AptosResult<Vec<Event>>
pub async fn get_events_by_account( &self, address: AccountAddress, limit: Option<u32>, ) -> AptosResult<Vec<Event>>
Sourcepub async fn get_collection(
&self,
collection_address: AccountAddress,
) -> AptosResult<Collection>
pub async fn get_collection( &self, collection_address: AccountAddress, ) -> AptosResult<Collection>
Sourcepub async fn get_collection_tokens(
&self,
collection_address: AccountAddress,
pagination: Option<PaginationParams>,
) -> AptosResult<Page<TokenBalance>>
pub async fn get_collection_tokens( &self, collection_address: AccountAddress, pagination: Option<PaginationParams>, ) -> AptosResult<Page<TokenBalance>>
Sourcepub async fn get_coin_balances(
&self,
address: AccountAddress,
) -> AptosResult<Vec<CoinBalance>>
pub async fn get_coin_balances( &self, address: AccountAddress, ) -> AptosResult<Vec<CoinBalance>>
Sourcepub async fn get_coin_activities(
&self,
address: AccountAddress,
limit: Option<u32>,
) -> AptosResult<Vec<CoinActivity>>
pub async fn get_coin_activities( &self, address: AccountAddress, limit: Option<u32>, ) -> AptosResult<Vec<CoinActivity>>
Sourcepub async fn get_processor_status(&self) -> AptosResult<Vec<ProcessorStatus>>
pub async fn get_processor_status(&self) -> AptosResult<Vec<ProcessorStatus>>
Sourcepub async fn get_indexer_version(&self) -> AptosResult<u64>
pub async fn get_indexer_version(&self) -> AptosResult<u64>
Gets the current indexer version (last processed transaction).
§Errors
Returns an error if the processor status cannot be fetched, or if no processor status is available.
Sourcepub async fn check_indexer_lag(
&self,
reference_version: u64,
max_lag: u64,
) -> AptosResult<bool>
pub async fn check_indexer_lag( &self, reference_version: u64, max_lag: u64, ) -> AptosResult<bool>
Checks if the indexer is healthy by comparing with a reference version.
§Errors
Returns an error if the indexer version cannot be fetched (see get_indexer_version for details).
Trait Implementations§
Source§impl Clone for IndexerClient
impl Clone for IndexerClient
Source§fn clone(&self) -> IndexerClient
fn clone(&self) -> IndexerClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more