pub struct Client { /* private fields */ }Expand description
Client for interacting with the Koios API
Implementations§
Source§impl Client
impl Client
Sourcepub async fn get_account_list(&self) -> Result<Vec<AccountList>>
pub async fn get_account_list(&self) -> Result<Vec<AccountList>>
Get a list of all stake addresses that have at least 1 transaction
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let accounts = client.get_account_list().await?;
println!("Account list: {:?}", accounts);
Ok(())
}Sourcepub async fn get_account_info(
&self,
stake_addresses: &[String],
) -> Result<Vec<AccountInfo>>
pub async fn get_account_info( &self, stake_addresses: &[String], ) -> Result<Vec<AccountInfo>>
Get the account information for given stake addresses
§Arguments
stake_addresses- List of stake addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let account_info = client.get_account_info(&stake_addresses).await?;
println!("Account info: {:?}", account_info);
Ok(())
}Sourcepub async fn get_account_info_cached(
&self,
stake_addresses: &[String],
) -> Result<Vec<AccountInfo>>
pub async fn get_account_info_cached( &self, stake_addresses: &[String], ) -> Result<Vec<AccountInfo>>
Get the cached account information for given stake addresses
§Arguments
stake_addresses- List of stake addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let account_info = client.get_account_info_cached(&stake_addresses).await?;
println!("Cached account info: {:?}", account_info);
Ok(())
}Sourcepub async fn get_account_utxos(
&self,
stake_addresses: &[String],
extended: Option<bool>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_account_utxos( &self, stake_addresses: &[String], extended: Option<bool>, ) -> Result<Vec<UtxoInfo>>
Get a list of all UTxOs for given stake addresses
§Arguments
stake_addresses- List of stake addresses to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let utxos = client.get_account_utxos(&stake_addresses, Some(true)).await?;
println!("Account UTXOs: {:?}", utxos);
Ok(())
}Sourcepub async fn get_account_transactions(
&self,
stake_address: StakeAddress,
after_block_height: Option<AfterBlockHeight>,
) -> Result<Vec<AddressTransaction>>
pub async fn get_account_transactions( &self, stake_address: StakeAddress, after_block_height: Option<AfterBlockHeight>, ) -> Result<Vec<AddressTransaction>>
Get a list of all transactions for a given stake address
§Arguments
stake_address- Stake address to queryafter_block_height- Optional block height to filter from
§Examples
use koios_sdk::Client;
use koios_sdk::types::{StakeAddress, AfterBlockHeight};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_address = "stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7";
let txs = client.get_account_transactions(
StakeAddress::new(stake_address),
Some(AfterBlockHeight::new(42000000))
).await?;
println!("Account transactions: {:?}", txs);
Ok(())
}Sourcepub async fn get_account_rewards(
&self,
stake_addresses: &[String],
epoch_no: Option<String>,
) -> Result<Vec<AccountRewards>>
pub async fn get_account_rewards( &self, stake_addresses: &[String], epoch_no: Option<String>, ) -> Result<Vec<AccountRewards>>
Get the full rewards history for given stake addresses
§Arguments
stake_addresses- List of stake addresses to queryepoch_no- Optional epoch number to query from
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let epoch_no = Some("320".to_string());
let rewards = client.get_account_rewards(&stake_addresses, epoch_no).await?;
println!("Account rewards: {:?}", rewards);
Ok(())
}Sourcepub async fn get_account_updates(
&self,
stake_addresses: &[String],
) -> Result<Vec<AccountUpdates>>
pub async fn get_account_updates( &self, stake_addresses: &[String], ) -> Result<Vec<AccountUpdates>>
Get the account updates for given stake addresses
§Arguments
stake_addresses- List of stake addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let updates = client.get_account_updates(&stake_addresses).await?;
println!("Account updates: {:?}", updates);
Ok(())
}Sourcepub async fn get_account_addresses(
&self,
stake_addresses: &[String],
first_only: Option<bool>,
empty: Option<bool>,
) -> Result<Vec<AccountAddresses>>
pub async fn get_account_addresses( &self, stake_addresses: &[String], first_only: Option<bool>, empty: Option<bool>, ) -> Result<Vec<AccountAddresses>>
Get all addresses associated with given staking accounts
§Arguments
stake_addresses- List of stake addresses to queryfirst_only- Optional flag to return only the first addressempty- Optional flag to include empty addresses
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let addresses = client.get_account_addresses(
&stake_addresses,
Some(true),
Some(false)
).await?;
println!("Account addresses: {:?}", addresses);
Ok(())
}Sourcepub async fn get_account_assets(
&self,
stake_addresses: &[String],
) -> Result<Vec<AccountAssets>>
pub async fn get_account_assets( &self, stake_addresses: &[String], ) -> Result<Vec<AccountAssets>>
Get the native asset balance for given stake addresses
§Arguments
stake_addresses- List of stake addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let assets = client.get_account_assets(&stake_addresses).await?;
println!("Account assets: {:?}", assets);
Ok(())
}Sourcepub async fn get_account_history(
&self,
stake_addresses: &[String],
epoch_no: Option<String>,
) -> Result<Vec<AccountHistory>>
pub async fn get_account_history( &self, stake_addresses: &[String], epoch_no: Option<String>, ) -> Result<Vec<AccountHistory>>
Get the staking history of given stake addresses
§Arguments
stake_addresses- List of stake addresses to queryepoch_no- Optional epoch number to query from
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let stake_addresses = vec![
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7".to_string()
];
let epoch_no = Some("320".to_string());
let history = client.get_account_history(&stake_addresses, epoch_no).await?;
println!("Account history: {:?}", history);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_address_info(
&self,
addresses: &[String],
) -> Result<Vec<AddressInfo>>
pub async fn get_address_info( &self, addresses: &[String], ) -> Result<Vec<AddressInfo>>
Get address info - balance, associated stake address (if any) and UTxO set for given addresses
§Arguments
addresses- List of addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let addresses = vec![
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz".to_string()
];
let address_info = client.get_address_info(&addresses).await?;
println!("Address info: {:?}", address_info);
Ok(())
}Sourcepub async fn get_address_utxos(
&self,
addresses: &[String],
extended: Option<bool>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_address_utxos( &self, addresses: &[String], extended: Option<bool>, ) -> Result<Vec<UtxoInfo>>
Get UTxO set for given addresses
§Arguments
addresses- List of addresses to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let addresses = vec![
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz".to_string()
];
let utxos = client.get_address_utxos(&addresses, Some(true)).await?;
println!("Address UTXOs: {:?}", utxos);
Ok(())
}Sourcepub async fn get_credential_utxos(
&self,
payment_credentials: &[String],
extended: Option<bool>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_credential_utxos( &self, payment_credentials: &[String], extended: Option<bool>, ) -> Result<Vec<UtxoInfo>>
Get UTxO details for requested payment credentials
§Arguments
payment_credentials- List of payment credentials to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let credentials = vec![
"025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52".to_string()
];
let utxos = client.get_credential_utxos(&credentials, Some(true)).await?;
println!("Credential UTXOs: {:?}", utxos);
Ok(())
}Sourcepub async fn get_address_transactions(
&self,
addresses: &[String],
after_block_height: Option<u64>,
) -> Result<Vec<AddressTransaction>>
pub async fn get_address_transactions( &self, addresses: &[String], after_block_height: Option<u64>, ) -> Result<Vec<AddressTransaction>>
Get the transaction hash list of input address array, optionally filtering after specified block height
§Arguments
addresses- List of addresses to queryafter_block_height- Optional block height to filter from
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let addresses = vec![
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz".to_string()
];
let txs = client.get_address_transactions(&addresses, Some(42000000)).await?;
println!("Address transactions: {:?}", txs);
Ok(())
}Sourcepub async fn get_credential_transactions(
&self,
payment_credentials: &[String],
after_block_height: Option<u64>,
) -> Result<Vec<AddressTransaction>>
pub async fn get_credential_transactions( &self, payment_credentials: &[String], after_block_height: Option<u64>, ) -> Result<Vec<AddressTransaction>>
Get the transaction hash list of input payment credential array, optionally filtering after specified block height
§Arguments
payment_credentials- List of payment credentials to queryafter_block_height- Optional block height to filter from
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let credentials = vec![
"025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52".to_string()
];
let txs = client.get_credential_transactions(&credentials, Some(42000000)).await?;
println!("Credential transactions: {:?}", txs);
Ok(())
}Sourcepub async fn get_address_assets(
&self,
addresses: &[String],
) -> Result<Vec<AddressAsset>>
pub async fn get_address_assets( &self, addresses: &[String], ) -> Result<Vec<AddressAsset>>
Get the list of all the assets (policy, name and quantity) for given addresses
§Arguments
addresses- List of addresses to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let addresses = vec![
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz".to_string()
];
let assets = client.get_address_assets(&addresses).await?;
println!("Address assets: {:?}", assets);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_asset_list(&self) -> Result<Vec<AssetList>>
pub async fn get_asset_list(&self) -> Result<Vec<AssetList>>
Get the list of all native assets (paginated)
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let assets = client.get_asset_list().await?;
println!("Asset list: {:?}", assets);
Ok(())
}Sourcepub async fn get_policy_asset_list(
&self,
policy_id: &AssetPolicy,
) -> Result<Vec<PolicyAssetList>>
pub async fn get_policy_asset_list( &self, policy_id: &AssetPolicy, ) -> Result<Vec<PolicyAssetList>>
Get the list of assets under the given policy (including balances)
§Arguments
policy_id- Policy ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::AssetPolicy;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let assets = client.get_policy_asset_list(&policy_id).await?;
println!("Policy assets: {:?}", assets);
Ok(())
}Sourcepub async fn get_asset_token_registry(&self) -> Result<Vec<AssetTokenRegistry>>
pub async fn get_asset_token_registry(&self) -> Result<Vec<AssetTokenRegistry>>
Get a list of assets registered via token registry on github
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let registry = client.get_asset_token_registry().await?;
println!("Token registry: {:?}", registry);
Ok(())
}Sourcepub async fn get_asset_info(
&self,
asset_list: &[Vec<String>],
) -> Result<Vec<AssetInfo>>
pub async fn get_asset_info( &self, asset_list: &[Vec<String>], ) -> Result<Vec<AssetInfo>>
Get the information of a list of assets including first minting & token registry metadata
§Arguments
asset_list- List of asset pairs (policy_id, asset_name) to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let asset_list = vec![
vec![
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209".to_string(),
"token1".to_string()
]
];
let asset_info = client.get_asset_info(&asset_list).await?;
println!("Asset info: {:?}", asset_info);
Ok(())
}Sourcepub async fn get_asset_utxos(
&self,
asset_list: &[Vec<String>],
extended: Option<bool>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_asset_utxos( &self, asset_list: &[Vec<String>], extended: Option<bool>, ) -> Result<Vec<UtxoInfo>>
Get the UTXO information of a list of assets
§Arguments
asset_list- List of asset pairs (policy_id, asset_name) to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let asset_list = vec![
vec![
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209".to_string(),
"token1".to_string()
]
];
let utxos = client.get_asset_utxos(&asset_list, Some(true)).await?;
println!("Asset UTXOs: {:?}", utxos);
Ok(())
}Sourcepub async fn get_asset_history(
&self,
policy_id: &AssetPolicy,
asset_name: &AssetName,
) -> Result<Vec<AssetHistory>>
pub async fn get_asset_history( &self, policy_id: &AssetPolicy, asset_name: &AssetName, ) -> Result<Vec<AssetHistory>>
Get the mint/burn history of an asset
§Arguments
policy_id- Policy ID to queryasset_name- Asset name to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::{AssetPolicy, AssetName};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let asset_name = AssetName::new("token1");
let history = client.get_asset_history(&policy_id, &asset_name).await?;
println!("Asset history: {:?}", history);
Ok(())
}Sourcepub async fn get_asset_nft_address(
&self,
policy_id: &AssetPolicyNft,
asset_name: &AssetNameNft,
) -> Result<Vec<AssetNftAddress>>
pub async fn get_asset_nft_address( &self, policy_id: &AssetPolicyNft, asset_name: &AssetNameNft, ) -> Result<Vec<AssetNftAddress>>
Get the address where specified NFT currently resides
§Arguments
policy_id- NFT policy ID to queryasset_name- NFT asset name to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::{AssetPolicyNft, AssetNameNft};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicyNft::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let asset_name = AssetNameNft::new("nft1");
let address = client.get_asset_nft_address(&policy_id, &asset_name).await?;
println!("NFT address: {:?}", address);
Ok(())
}Sourcepub async fn get_policy_asset_addresses(
&self,
policy_id: &AssetPolicy,
) -> Result<Vec<PolicyAssetAddresses>>
pub async fn get_policy_asset_addresses( &self, policy_id: &AssetPolicy, ) -> Result<Vec<PolicyAssetAddresses>>
Get the list of addresses with quantity for each asset on the given policy
§Arguments
policy_id- Policy ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::AssetPolicy;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let addresses = client.get_policy_asset_addresses(&policy_id).await?;
println!("Policy asset addresses: {:?}", addresses);
Ok(())
}Sourcepub async fn get_policy_asset_info(
&self,
policy_id: &AssetPolicy,
) -> Result<Vec<PolicyAssetInfo>>
pub async fn get_policy_asset_info( &self, policy_id: &AssetPolicy, ) -> Result<Vec<PolicyAssetInfo>>
Get the information for all assets under the same policy
§Arguments
policy_id- Policy ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::AssetPolicy;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let info = client.get_policy_asset_info(&policy_id).await?;
println!("Policy asset info: {:?}", info);
Ok(())
}Sourcepub async fn get_policy_asset_mints(
&self,
policy_id: &AssetPolicy,
) -> Result<Vec<PolicyAssetMint>>
pub async fn get_policy_asset_mints( &self, policy_id: &AssetPolicy, ) -> Result<Vec<PolicyAssetMint>>
Get a list of mint or burn count details for all assets minted under a policy
§Arguments
policy_id- Policy ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::AssetPolicy;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let mints = client.get_policy_asset_mints(&policy_id).await?;
println!("Policy asset mints: {:?}", mints);
Ok(())
}Sourcepub async fn get_asset_summary(
&self,
policy_id: &AssetPolicy,
asset_name: &AssetName,
) -> Result<Vec<AssetSummary>>
pub async fn get_asset_summary( &self, policy_id: &AssetPolicy, asset_name: &AssetName, ) -> Result<Vec<AssetSummary>>
Get the summary of an asset
§Arguments
policy_id- Policy ID to queryasset_name- Asset name to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::{AssetPolicy, AssetName};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let asset_name = AssetName::new("token1");
let summary = client.get_asset_summary(&policy_id, &asset_name).await?;
println!("Asset summary: {:?}", summary);
Ok(())
}Sourcepub async fn get_asset_transactions(
&self,
policy_id: &AssetPolicy,
asset_name: &AssetName,
after_block_height: Option<AfterBlockHeight>,
history: Option<bool>,
) -> Result<Vec<AddressTransaction>>
pub async fn get_asset_transactions( &self, policy_id: &AssetPolicy, asset_name: &AssetName, after_block_height: Option<AfterBlockHeight>, history: Option<bool>, ) -> Result<Vec<AddressTransaction>>
Get the list of current or all asset transaction hashes
§Arguments
policy_id- Policy ID to queryasset_name- Asset name to queryafter_block_height- Optional block height to filter fromhistory- Optional flag to include historical transactions
§Examples
use koios_sdk::Client;
use koios_sdk::types::{AssetPolicy, AssetName, AfterBlockHeight};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let policy_id = AssetPolicy::new(
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209"
);
let asset_name = AssetName::new("token1");
let txs = client.get_asset_transactions(
&policy_id,
&asset_name,
Some(AfterBlockHeight::new(42000000)),
Some(true)
).await?;
println!("Asset transactions: {:?}", txs);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_blocks(&self) -> Result<Vec<Block>>
pub async fn get_blocks(&self) -> Result<Vec<Block>>
Get summarized details about all blocks (paginated - latest first)
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let blocks = client.get_blocks().await?;
println!("Latest blocks: {:?}", blocks);
Ok(())
}Sourcepub async fn get_block_info(
&self,
block_hashes: &[String],
) -> Result<Vec<BlockInfo>>
pub async fn get_block_info( &self, block_hashes: &[String], ) -> Result<Vec<BlockInfo>>
Get detailed information about specific blocks
§Arguments
block_hashes- Vector of block hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let block_hashes = vec![
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e".to_string()
];
let block_info = client.get_block_info(&block_hashes).await?;
println!("Block info: {:?}", block_info);
Ok(())
}Sourcepub async fn get_block_transactions(
&self,
block_hashes: &[String],
) -> Result<Vec<BlockTransaction>>
pub async fn get_block_transactions( &self, block_hashes: &[String], ) -> Result<Vec<BlockTransaction>>
Get a list of all transactions included in provided blocks
§Arguments
block_hashes- Vector of block hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let block_hashes = vec![
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e".to_string()
];
let block_txs = client.get_block_transactions(&block_hashes).await?;
println!("Block transactions: {:?}", block_txs);
Ok(())
}Sourcepub async fn get_block_transaction_cbor(
&self,
block_hashes: &[String],
) -> Result<Vec<BlockTransactionCbor>>
pub async fn get_block_transaction_cbor( &self, block_hashes: &[String], ) -> Result<Vec<BlockTransactionCbor>>
Get raw CBOR data for all transactions within requested blocks
§Arguments
block_hashes- Vector of block hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let block_hashes = vec![
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e".to_string()
];
let tx_cbor = client.get_block_transaction_cbor(&block_hashes).await?;
println!("Transaction CBOR: {:?}", tx_cbor);
Ok(())
}Sourcepub async fn get_block_transaction_info(
&self,
options: &BlockTxInfoRequest,
) -> Result<Vec<TransactionInfo>>
👎Deprecated: This endpoint is deprecated in the Koios API
pub async fn get_block_transaction_info( &self, options: &BlockTxInfoRequest, ) -> Result<Vec<TransactionInfo>>
Get detailed information about transactions for requested blocks
§Arguments
block_hashes- Vector of block hashes to queryoptions- Optional parameters for customizing the response
§Examples
use koios_sdk::Client;
use koios_sdk::models::BlockTxInfoRequest;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let block_hashes = vec![
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e".to_string()
];
let options = BlockTxInfoRequest {
block_hashes,
inputs: Some(true),
metadata: Some(true),
..Default::default()
};
let tx_info = client.get_block_transaction_info(&options).await?;
println!("Transaction info: {:?}", tx_info);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_epoch_info(
&self,
epoch_no: Option<EpochNo>,
include_next_epoch: Option<IncludeNextEpoch>,
) -> Result<Vec<EpochInfo>>
pub async fn get_epoch_info( &self, epoch_no: Option<EpochNo>, include_next_epoch: Option<IncludeNextEpoch>, ) -> Result<Vec<EpochInfo>>
Get the epoch information, all epochs if no epoch specified
§Arguments
epoch_no- Optional epoch number to queryinclude_next_epoch- Whether to include information about nearing but not yet started epoch
§Examples
use koios_sdk::{Client, types::{EpochNo, IncludeNextEpoch}};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
// Get all epochs
let all_epochs = client.get_epoch_info(None, None).await?;
// Get specific epoch with next epoch info
let epoch = client.get_epoch_info(
Some(EpochNo::new("320")),
Some(IncludeNextEpoch::new(true))
).await?;
Ok(())
}Sourcepub async fn get_epoch_params(
&self,
epoch_no: Option<EpochNo>,
) -> Result<Vec<EpochParams>>
pub async fn get_epoch_params( &self, epoch_no: Option<EpochNo>, ) -> Result<Vec<EpochParams>>
Get the protocol parameters for specific epoch, returns information about all epochs if no epoch specified
§Arguments
epoch_no- Optional epoch number to query
§Examples
use koios_sdk::{Client, types::EpochNo};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
// Get all epochs' parameters
let all_params = client.get_epoch_params(None).await?;
// Get specific epoch parameters
let params = client.get_epoch_params(Some(EpochNo::new("320"))).await?;
Ok(())
}Sourcepub async fn get_epoch_block_protocols(
&self,
epoch_no: Option<EpochNo>,
) -> Result<Vec<EpochBlockProtocol>>
pub async fn get_epoch_block_protocols( &self, epoch_no: Option<EpochNo>, ) -> Result<Vec<EpochBlockProtocol>>
Get block protocol versions for specific epoch, returns information about all epochs if no epoch specified
§Arguments
epoch_no- Optional epoch number to query
§Examples
use koios_sdk::{Client, types::EpochNo};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
// Get all epochs' block protocols
let all_protocols = client.get_epoch_block_protocols(None).await?;
// Get specific epoch block protocols
let protocols = client.get_epoch_block_protocols(Some(EpochNo::new("320"))).await?;
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_drep_epoch_summary(
&self,
epoch_no: Option<EpochNo>,
) -> Result<Vec<DrepEpochSummary>>
pub async fn get_drep_epoch_summary( &self, epoch_no: Option<EpochNo>, ) -> Result<Vec<DrepEpochSummary>>
Get summary of voting power and DRep count for each epoch
§Arguments
epoch_no- Optional epoch number to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::EpochNo;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let summary = client.get_drep_epoch_summary(Some(EpochNo::new("320"))).await?;
println!("DRep epoch summary: {:?}", summary);
Ok(())
}Sourcepub async fn get_drep_list(&self) -> Result<Vec<DrepInfo>>
pub async fn get_drep_list(&self) -> Result<Vec<DrepInfo>>
Get list of all active delegated representatives (DReps)
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let dreps = client.get_drep_list().await?;
println!("DRep list: {:?}", dreps);
Ok(())
}Sourcepub async fn get_drep_info(&self, drep_ids: &[String]) -> Result<Vec<DrepInfo>>
pub async fn get_drep_info(&self, drep_ids: &[String]) -> Result<Vec<DrepInfo>>
Get detailed information about requested delegated representatives (DReps)
§Arguments
drep_ids- List of DRep IDs to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let drep_ids = vec![
"drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g".to_string()
];
let info = client.get_drep_info(&drep_ids).await?;
println!("DRep info: {:?}", info);
Ok(())
}Sourcepub async fn get_drep_metadata(
&self,
drep_ids: &[String],
) -> Result<Vec<DrepMetadata>>
pub async fn get_drep_metadata( &self, drep_ids: &[String], ) -> Result<Vec<DrepMetadata>>
Get metadata for requested delegated representatives (DReps)
§Arguments
drep_ids- List of DRep IDs to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let drep_ids = vec![
"drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g".to_string()
];
let metadata = client.get_drep_metadata(&drep_ids).await?;
println!("DRep metadata: {:?}", metadata);
Ok(())
}Sourcepub async fn get_drep_updates(
&self,
drep_id: Option<DrepId>,
) -> Result<Vec<DrepUpdate>>
pub async fn get_drep_updates( &self, drep_id: Option<DrepId>, ) -> Result<Vec<DrepUpdate>>
Get list of updates for requested (or all) delegated representatives (DReps)
§Arguments
drep_id- Optional DRep ID to filter by
§Examples
use koios_sdk::Client;
use koios_sdk::types::DrepId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let updates = client.get_drep_updates(
Some(DrepId::new("drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g"))
).await?;
println!("DRep updates: {:?}", updates);
Ok(())
}Sourcepub async fn get_drep_history(
&self,
epoch_no: Option<EpochNo>,
drep_id: Option<DrepId>,
) -> Result<Vec<DrepHistory>>
pub async fn get_drep_history( &self, epoch_no: Option<EpochNo>, drep_id: Option<DrepId>, ) -> Result<Vec<DrepHistory>>
Get history of DReps voting power against each (or requested) epoch
§Arguments
epoch_no- Optional epoch number to querydrep_id- Optional DRep ID to filter by
§Examples
use koios_sdk::Client;
use koios_sdk::types::{EpochNo, DrepId};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let history = client.get_drep_history(
Some(EpochNo::new("320")),
Some(DrepId::new("drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g"))
).await?;
println!("DRep history: {:?}", history);
Ok(())
}Sourcepub async fn get_drep_votes(&self, drep_id: &DrepId) -> Result<Vec<DrepVote>>
pub async fn get_drep_votes(&self, drep_id: &DrepId) -> Result<Vec<DrepVote>>
Get list of all votes casted by requested delegated representative (DRep)
§Arguments
drep_id- DRep ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::DrepId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let votes = client.get_drep_votes(
&DrepId::new("drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g")
).await?;
println!("DRep votes: {:?}", votes);
Ok(())
}Sourcepub async fn get_committee_info(&self) -> Result<Vec<CommitteeInfo>>
pub async fn get_committee_info(&self) -> Result<Vec<CommitteeInfo>>
Get information about active committee and its members
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let info = client.get_committee_info().await?;
println!("Committee info: {:?}", info);
Ok(())
}Sourcepub async fn get_committee_votes(
&self,
cc_hot_id: &CcHotId,
) -> Result<Vec<CommitteeVotes>>
pub async fn get_committee_votes( &self, cc_hot_id: &CcHotId, ) -> Result<Vec<CommitteeVotes>>
Get list of all votes cast by given committee member or collective
§Arguments
cc_hot_id- Committee member hot key ID
§Examples
use koios_sdk::Client;
use koios_sdk::types::CcHotId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let votes = client.get_committee_votes(
&CcHotId::new("cc_hot1abcdef1234567890abcdef1234567890abcdef1234567890abcdef123456")
).await?;
println!("Committee votes: {:?}", votes);
Ok(())
}Sourcepub async fn get_proposal_list(&self) -> Result<Vec<ProposalList>>
pub async fn get_proposal_list(&self) -> Result<Vec<ProposalList>>
Get list of all governance proposals
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let proposals = client.get_proposal_list().await?;
println!("Proposal list: {:?}", proposals);
Ok(())
}Sourcepub async fn get_voter_proposal_list(
&self,
voter_id: &VoterId,
) -> Result<Vec<VoterProposalList>>
pub async fn get_voter_proposal_list( &self, voter_id: &VoterId, ) -> Result<Vec<VoterProposalList>>
Get list of all governance proposals for specified DRep, SPO or Committee credential
§Arguments
voter_id- Voter ID (DRep, SPO, or Committee credential)
§Examples
use koios_sdk::Client;
use koios_sdk::types::VoterId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let proposals = client.get_voter_proposal_list(
&VoterId::new("drep1arlq6qcjf8qd7kn03k8lqg6gxv7zw9r8684fa03akqfx7qarhgjqka6e5g")
).await?;
println!("Voter proposal list: {:?}", proposals);
Ok(())
}Sourcepub async fn get_proposal_voting_summary(
&self,
proposal_id: &ProposalId,
) -> Result<Vec<ProposalVotingSummary>>
pub async fn get_proposal_voting_summary( &self, proposal_id: &ProposalId, ) -> Result<Vec<ProposalVotingSummary>>
Get summary of votes for given proposal
§Arguments
proposal_id- Proposal ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::ProposalId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let summary = client.get_proposal_voting_summary(
&ProposalId::new("gov_action1abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
).await?;
println!("Proposal voting summary: {:?}", summary);
Ok(())
}Sourcepub async fn get_proposal_votes(
&self,
proposal_id: &ProposalId,
) -> Result<Vec<ProposalVote>>
pub async fn get_proposal_votes( &self, proposal_id: &ProposalId, ) -> Result<Vec<ProposalVote>>
Get list of all votes cast on specified governance action
§Arguments
proposal_id- Proposal ID to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::ProposalId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let votes = client.get_proposal_votes(
&ProposalId::new("gov_action1abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
).await?;
println!("Proposal votes: {:?}", votes);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_tip(&self) -> Result<Vec<Tip>>
pub async fn get_tip(&self) -> Result<Vec<Tip>>
Get the tip info about the latest block seen by chain
Sourcepub async fn get_genesis(&self) -> Result<Vec<Genesis>>
pub async fn get_genesis(&self) -> Result<Vec<Genesis>>
Get the Genesis parameters used to start specific era on chain
Sourcepub async fn get_totals(&self, epoch_no: Option<EpochNo>) -> Result<Vec<Totals>>
pub async fn get_totals(&self, epoch_no: Option<EpochNo>) -> Result<Vec<Totals>>
Get the circulating utxo, treasury, rewards, supply and reserves in lovelace for specified epoch, all epochs if empty
Sourcepub async fn get_param_updates(&self) -> Result<Vec<ParamUpdate>>
pub async fn get_param_updates(&self) -> Result<Vec<ParamUpdate>>
Get all parameter update proposals submitted to the chain starting Shelley era
Sourcepub async fn get_cli_protocol_params(&self) -> Result<Vec<CliProtocolParams>>
pub async fn get_cli_protocol_params(&self) -> Result<Vec<CliProtocolParams>>
Get Current Protocol Parameters as published by cardano-cli
Sourcepub async fn get_reserve_withdrawals(&self) -> Result<Vec<ReserveWithdrawal>>
pub async fn get_reserve_withdrawals(&self) -> Result<Vec<ReserveWithdrawal>>
List of all withdrawals from reserves against stake accounts
Sourcepub async fn get_treasury_withdrawals(&self) -> Result<Vec<ReserveWithdrawal>>
pub async fn get_treasury_withdrawals(&self) -> Result<Vec<ReserveWithdrawal>>
List of all withdrawals from treasury against stake accounts
Source§impl Client
impl Client
Sourcepub async fn query_ogmios(
&self,
method: &str,
params: Option<Value>,
) -> Result<OgmiosTip>
pub async fn query_ogmios( &self, method: &str, params: Option<Value>, ) -> Result<OgmiosTip>
Query the Ogmios service with a custom request
§Arguments
method- The Ogmios method to callparams- Optional parameters for the method
§Examples
use koios_sdk::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
// Query network tip
let tip = client.query_ogmios("queryNetwork/tip", None).await?;
println!("Network tip: {:?}", tip);
// Query with parameters
let params = json!({
"query": "someQuery",
"value": 123
});
let result = client.query_ogmios("someMethod", Some(params)).await?;
println!("Query result: {:?}", result);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_pool_list(&self) -> Result<Vec<PoolList>>
pub async fn get_pool_list(&self) -> Result<Vec<PoolList>>
Get list of brief info for all pools
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pools = client.get_pool_list().await?;
println!("Pool list: {:?}", pools);
Ok(())
}Sourcepub async fn get_pool_info(&self, pool_ids: &[String]) -> Result<Vec<PoolInfo>>
pub async fn get_pool_info(&self, pool_ids: &[String]) -> Result<Vec<PoolInfo>>
Get current pool statuses and details for a specified list of pool ids
§Arguments
pool_ids- List of pool IDs to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_ids = vec![
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy".to_string()
];
let info = client.get_pool_info(&pool_ids).await?;
println!("Pool info: {:?}", info);
Ok(())
}Sourcepub async fn get_pool_stake_snapshot(
&self,
pool_bech32: &PoolBech32,
) -> Result<Vec<PoolSnapshot>>
pub async fn get_pool_stake_snapshot( &self, pool_bech32: &PoolBech32, ) -> Result<Vec<PoolSnapshot>>
Get Mark, Set and Go stake snapshots for the selected pool
§Arguments
pool_bech32- Pool ID in bech32 format
§Examples
use koios_sdk::Client;
use koios_sdk::types::PoolBech32;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let snapshot = client.get_pool_stake_snapshot(&pool_id).await?;
println!("Pool stake snapshot: {:?}", snapshot);
Ok(())
}Sourcepub async fn get_pool_delegators(
&self,
pool_bech32: &PoolBech32,
) -> Result<Vec<PoolDelegator>>
pub async fn get_pool_delegators( &self, pool_bech32: &PoolBech32, ) -> Result<Vec<PoolDelegator>>
Get information about live delegators for a given pool
§Arguments
pool_bech32- Pool ID in bech32 format
§Examples
use koios_sdk::Client;
use koios_sdk::types::PoolBech32;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let delegators = client.get_pool_delegators(&pool_id).await?;
println!("Pool delegators: {:?}", delegators);
Ok(())
}Sourcepub async fn get_pool_delegators_history(
&self,
pool_bech32: &PoolBech32,
epoch_no: Option<EpochNo>,
) -> Result<Vec<PoolDelegatorsHistory>>
pub async fn get_pool_delegators_history( &self, pool_bech32: &PoolBech32, epoch_no: Option<EpochNo>, ) -> Result<Vec<PoolDelegatorsHistory>>
Get information about active delegators (incl. history) for a given pool and epoch number
§Arguments
pool_bech32- Pool ID in bech32 formatepoch_no- Optional epoch number to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::{PoolBech32, EpochNo};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let history = client.get_pool_delegators_history(
&pool_id,
Some(EpochNo::new("320"))
).await?;
println!("Pool delegators history: {:?}", history);
Ok(())
}Sourcepub async fn get_pool_history(
&self,
pool_bech32: &PoolBech32,
epoch_no: Option<EpochNo>,
) -> Result<Vec<PoolHistoryInfo>>
pub async fn get_pool_history( &self, pool_bech32: &PoolBech32, epoch_no: Option<EpochNo>, ) -> Result<Vec<PoolHistoryInfo>>
Get pool stake, block and reward history for a specific epoch or all epochs
§Arguments
pool_bech32- Pool ID in bech32 formatepoch_no- Optional epoch number to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::{PoolBech32, EpochNo};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let history = client.get_pool_history(
&pool_id,
Some(EpochNo::new("320"))
).await?;
println!("Pool history: {:?}", history);
Ok(())
}Sourcepub async fn get_pool_updates(
&self,
pool_bech32: Option<&PoolBech32>,
) -> Result<Vec<PoolUpdate>>
pub async fn get_pool_updates( &self, pool_bech32: Option<&PoolBech32>, ) -> Result<Vec<PoolUpdate>>
Get update history for all pools or a specific pool
§Arguments
pool_bech32- Optional pool ID in bech32 format to filter by
§Examples
use koios_sdk::Client;
use koios_sdk::types::PoolBech32;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let updates = client.get_pool_updates(Some(&pool_id)).await?;
println!("Pool updates: {:?}", updates);
Ok(())
}Sourcepub async fn get_pool_registrations(
&self,
epoch_no: Option<EpochNo>,
) -> Result<Vec<PoolRegistration>>
pub async fn get_pool_registrations( &self, epoch_no: Option<EpochNo>, ) -> Result<Vec<PoolRegistration>>
Get all pool registrations initiated in the requested epoch
§Arguments
epoch_no- Optional epoch number to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::EpochNo;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let registrations = client.get_pool_registrations(
Some(EpochNo::new("320"))
).await?;
println!("Pool registrations: {:?}", registrations);
Ok(())
}Sourcepub async fn get_pool_retirements(
&self,
epoch_no: Option<EpochNo>,
) -> Result<Vec<PoolRegistration>>
pub async fn get_pool_retirements( &self, epoch_no: Option<EpochNo>, ) -> Result<Vec<PoolRegistration>>
Get all pool retirements initiated in the requested epoch
§Arguments
epoch_no- Optional epoch number to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::EpochNo;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let retirements = client.get_pool_retirements(
Some(EpochNo::new("320"))
).await?;
println!("Pool retirements: {:?}", retirements);
Ok(())
}Sourcepub async fn get_pool_relays(&self) -> Result<Vec<PoolRelay>>
pub async fn get_pool_relays(&self) -> Result<Vec<PoolRelay>>
Get a list of registered relays for all pools
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let relays = client.get_pool_relays().await?;
println!("Pool relays: {:?}", relays);
Ok(())
}Sourcepub async fn get_pool_votes(
&self,
pool_bech32: &PoolBech32,
) -> Result<Vec<PoolVotes>>
pub async fn get_pool_votes( &self, pool_bech32: &PoolBech32, ) -> Result<Vec<PoolVotes>>
Get list of all votes cast by a pool
§Arguments
pool_bech32- Pool ID in bech32 format
§Examples
use koios_sdk::Client;
use koios_sdk::types::PoolBech32;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_id = PoolBech32::new(
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
);
let votes = client.get_pool_votes(&pool_id).await?;
println!("Pool votes: {:?}", votes);
Ok(())
}Sourcepub async fn get_pool_metadata(
&self,
pool_ids: Option<&[String]>,
) -> Result<Vec<PoolMetadataInfo>>
pub async fn get_pool_metadata( &self, pool_ids: Option<&[String]>, ) -> Result<Vec<PoolMetadataInfo>>
Get metadata (on & off-chain) for all pools or specific pools
§Arguments
pool_ids- Optional list of pool IDs to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let pool_ids = Some(vec![
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy".to_string()
]);
let metadata = client.get_pool_metadata(pool_ids.as_deref()).await?;
println!("Pool metadata: {:?}", metadata);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_script_info(
&self,
script_hashes: &[String],
) -> Result<Vec<ScriptInfo>>
pub async fn get_script_info( &self, script_hashes: &[String], ) -> Result<Vec<ScriptInfo>>
Get list of script information for given script hashes
§Arguments
script_hashes- List of script hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let script_hashes = vec![
"67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656".to_string()
];
let info = client.get_script_info(&script_hashes).await?;
println!("Script info: {:?}", info);
Ok(())
}Sourcepub async fn get_native_script_list(&self) -> Result<Vec<ScriptList>>
pub async fn get_native_script_list(&self) -> Result<Vec<ScriptList>>
Get list of all existing native script hashes along with their creation transaction hashes
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let scripts = client.get_native_script_list().await?;
println!("Native scripts: {:?}", scripts);
Ok(())
}Sourcepub async fn get_plutus_script_list(&self) -> Result<Vec<ScriptList>>
pub async fn get_plutus_script_list(&self) -> Result<Vec<ScriptList>>
Get list of all existing Plutus script hashes along with their creation transaction hashes
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let scripts = client.get_plutus_script_list().await?;
println!("Plutus scripts: {:?}", scripts);
Ok(())
}Sourcepub async fn get_script_redeemers(
&self,
script_hash: &ScriptHash,
) -> Result<Vec<ScriptRedeemer>>
pub async fn get_script_redeemers( &self, script_hash: &ScriptHash, ) -> Result<Vec<ScriptRedeemer>>
Get list of all redeemers for a given script hash
§Arguments
script_hash- Script hash to query
§Examples
use koios_sdk::Client;
use koios_sdk::types::ScriptHash;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let script_hash = ScriptHash::new(
"67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
);
let redeemers = client.get_script_redeemers(&script_hash).await?;
println!("Script redeemers: {:?}", redeemers);
Ok(())
}Sourcepub async fn get_script_utxos(
&self,
script_hash: &ScriptHash,
extended: Option<Extended>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_script_utxos( &self, script_hash: &ScriptHash, extended: Option<Extended>, ) -> Result<Vec<UtxoInfo>>
Get list of all UTXOs for a given script hash
§Arguments
script_hash- Script hash to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
use koios_sdk::types::{ScriptHash, Extended};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let script_hash = ScriptHash::new(
"67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
);
let utxos = client.get_script_utxos(&script_hash, Some(Extended::new(true))).await?;
println!("Script UTXOs: {:?}", utxos);
Ok(())
}Source§impl Client
impl Client
Sourcepub async fn get_utxo_info(
&self,
utxo_refs: &[String],
extended: Option<bool>,
) -> Result<Vec<UtxoInfo>>
pub async fn get_utxo_info( &self, utxo_refs: &[String], extended: Option<bool>, ) -> Result<Vec<UtxoInfo>>
Get UTxO set for requested UTxO references
§Arguments
utxo_refs- List of UTxO references to queryextended- Optional flag to include extended information
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let utxo_refs = vec!["1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef#1".to_string()];
let utxo_info = client.get_utxo_info(&utxo_refs, Some(true)).await?;
println!("UTxO info: {:?}", utxo_info);
Ok(())
}Sourcepub async fn get_transaction_cbor(
&self,
tx_hashes: &[String],
) -> Result<Vec<TransactionCbor>>
pub async fn get_transaction_cbor( &self, tx_hashes: &[String], ) -> Result<Vec<TransactionCbor>>
Get raw transaction(s) in CBOR format
§Arguments
tx_hashes- List of transaction hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let tx_hashes = vec!["1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef".to_string()];
let tx_cbor = client.get_transaction_cbor(&tx_hashes).await?;
println!("Transaction CBOR: {:?}", tx_cbor);
Ok(())
}Sourcepub async fn get_transaction_info(
&self,
options: &TransactionInfoRequest,
) -> Result<Vec<TransactionInfo>>
pub async fn get_transaction_info( &self, options: &TransactionInfoRequest, ) -> Result<Vec<TransactionInfo>>
Get detailed information about transaction(s)
§Arguments
tx_hashes- List of transaction hashes to queryoptions- Optional parameters for customizing the response
§Examples
use koios_sdk::Client;
use koios_sdk::models::requests::TransactionInfoRequest;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let tx_hashes = vec!["1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef".to_string()];
let options = TransactionInfoRequest {
tx_hashes,
inputs: Some(true),
..Default::default()
};
let tx_info = client.get_transaction_info(&options).await?;
println!("Transaction info: {:?}", tx_info);
Ok(())
}Sourcepub async fn get_transaction_metadata(
&self,
tx_hashes: &[String],
) -> Result<Vec<TransactionMetadata>>
pub async fn get_transaction_metadata( &self, tx_hashes: &[String], ) -> Result<Vec<TransactionMetadata>>
Get metadata information (if any) for given transaction(s)
§Arguments
tx_hashes- List of transaction hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let tx_hashes = vec!["1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef".to_string()];
let metadata = client.get_transaction_metadata(&tx_hashes).await?;
println!("Transaction metadata: {:?}", metadata);
Ok(())
}Sourcepub async fn get_transaction_metalabels(&self) -> Result<Vec<TxMetaLabels>>
pub async fn get_transaction_metalabels(&self) -> Result<Vec<TxMetaLabels>>
Get a list of all transaction metalabels
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let metalabels = client.get_transaction_metalabels().await?;
println!("Transaction metalabels: {:?}", metalabels);
Ok(())
}Sourcepub async fn submit_transaction(&self, cbor_data: &[u8]) -> Result<String>
pub async fn submit_transaction(&self, cbor_data: &[u8]) -> Result<String>
Submit an already serialized transaction to the network
§Arguments
cbor_data- Raw CBOR data of the serialized transaction
§Returns
The transaction ID as a hex string on success
§Errors
Returns an error if:
- The request fails
- The server returns a non-202 status code
- The response is not a valid transaction ID
Sourcepub async fn get_transaction_status(
&self,
tx_hashes: &[String],
) -> Result<Vec<TransactionStatus>>
pub async fn get_transaction_status( &self, tx_hashes: &[String], ) -> Result<Vec<TransactionStatus>>
Get the number of block confirmations for a given transaction hash list
§Arguments
tx_hashes- List of transaction hashes to query
§Examples
use koios_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new()?;
let tx_hashes = vec!["1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef".to_string()];
let status = client.get_transaction_status(&tx_hashes).await?;
println!("Transaction status: {:?}", status);
Ok(())
}Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create a new client builder
Sourcepub async fn get_auth_token(&self) -> Option<String>
pub async fn get_auth_token(&self) -> Option<String>
Get the authentication token if set (async version)
Sourcepub fn auth_token(&self) -> Option<String>
pub fn auth_token(&self) -> Option<String>
Get the authentication token if set (for compatibility)
Sourcepub async fn set_auth_token(&self, token: String)
pub async fn set_auth_token(&self, token: String)
Set authentication token with optional expiry
Sourcepub async fn set_auth_token_with_expiry(
&self,
token: String,
expiry: DateTime<Utc>,
)
pub async fn set_auth_token_with_expiry( &self, token: String, expiry: DateTime<Utc>, )
Set authentication token with expiry
Sourcepub async fn clear_auth_token(&self)
pub async fn clear_auth_token(&self)
Clear authentication token
Sourcepub async fn has_valid_auth(&self) -> bool
pub async fn has_valid_auth(&self) -> bool
Check if client has valid authentication