pub struct JupiterClient { /* private fields */ }Expand description
Main client for interacting with Jupiter API
Implementations§
Source§impl JupiterClient
impl JupiterClient
Sourcepub fn new() -> Result<Self, JupiterError>
pub fn new() -> Result<Self, JupiterError>
create a client Creates a new Jupiter client with default configuration
§Example
use jupiter_sdk::JupiterClient;
let client = JupiterClient::new().unwrap();Sourcepub fn from_base_url(base_url: String) -> Result<Self, JupiterError>
pub fn from_base_url(base_url: String) -> Result<Self, JupiterError>
create a client based on the URL, using the default configuration. Creates a client with custom base URL
§Example
use jupiter_sdk::JupiterClient;
let client = JupiterClient::from_base_url("https://quote-api.jup.ag".to_string()).unwrap();Sourcepub fn from_client(client: Client) -> Result<Self, JupiterError>
pub fn from_client(client: Client) -> Result<Self, JupiterError>
reate a client based on an existing client, using the default configuration.
Sourcepub fn from_config(config: ClientConfig) -> Result<Self, JupiterError>
pub fn from_config(config: ClientConfig) -> Result<Self, JupiterError>
create a client using configuration
Sourcepub fn with_rate_limit(requests_per_second: u32) -> Result<Self, JupiterError>
pub fn with_rate_limit(requests_per_second: u32) -> Result<Self, JupiterError>
create a client with rate limiting
Sourcepub async fn monitor_transaction(
&self,
signature: &str,
solana: &Solana,
config: Option<TransactionMonitorConfig>,
) -> Result<TransactionMonitorResult, JupiterError>
pub async fn monitor_transaction( &self, signature: &str, solana: &Solana, config: Option<TransactionMonitorConfig>, ) -> Result<TransactionMonitorResult, JupiterError>
Monitors transaction status
§Example
use jupiter_sdk::{JupiterClient, Solana};
let client = JupiterClient::new()?;
let solana = Solana::new(solana_network_sdk::types::Mode::MAIN)?;
let signature = "5verv...";
let result = client.monitor_transaction(signature, &solana, None).await?;Sourcepub async fn monitor_transactions_batch(
&self,
signatures: &[String],
solana: &Solana,
config: Option<TransactionMonitorConfig>,
) -> Result<Vec<TransactionMonitorResult>, JupiterError>
pub async fn monitor_transactions_batch( &self, signatures: &[String], solana: &Solana, config: Option<TransactionMonitorConfig>, ) -> Result<Vec<TransactionMonitorResult>, JupiterError>
Monitors multiple transactions in batch
Sourcepub async fn get_quote(
&self,
request: &QuoteRequest,
) -> Result<QuoteResponse, JupiterError>
pub async fn get_quote( &self, request: &QuoteRequest, ) -> Result<QuoteResponse, JupiterError>
Gets a quote for token swap
§Example
use jupiter_sdk::{JupiterClient, QuoteRequest};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let client = JupiterClient::new()?;
let request = QuoteRequest {
input_mint: "So11111111111111111111111111111111111111112".to_string(),
output_mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".to_string(),
amount: 1000000,
slippage_bps: 50,
fee_bps: None,
only_direct_routes: None,
as_legacy_transaction: None,
restrict_middle_tokens: None,
};
let quote = client.get_quote(&request).await?;
Ok(())
}Sourcepub async fn get_swap_transaction_data(
&self,
request: &SwapRequest,
) -> Result<SwapResponse, JupiterError>
pub async fn get_swap_transaction_data( &self, request: &SwapRequest, ) -> Result<SwapResponse, JupiterError>
Gets swap transaction data
§Example
use jupiter_sdk::{JupiterClient, SwapRequest, QuoteResponse};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let client = JupiterClient::new()?;
let quote = QuoteResponse { /* ... */ };
let request = SwapRequest {
quote_response: quote,
user_public_key: "YourPublicKeyHere".to_string(),
wrap_and_unwrap_sol: Some(true),
compute_unit_price: None,
prioritization_fee_lamports: None,
};
let swap_response = client.get_swap_transaction(&request).await?;
Ok(())
}Sourcepub async fn get_tokens(&self) -> Result<Vec<TokenInfo>, JupiterError>
pub async fn get_tokens(&self) -> Result<Vec<TokenInfo>, JupiterError>
Gets list of all supported tokens
Sourcepub async fn get_price(
&self,
ids: &[String],
) -> Result<HashMap<String, PriceResponse>, JupiterError>
pub async fn get_price( &self, ids: &[String], ) -> Result<HashMap<String, PriceResponse>, JupiterError>
Gets prices for multiple tokens
Sourcepub async fn get_routes(
&self,
input_mint: &str,
output_mint: &str,
amount: u64,
slippage_bps: u16,
) -> Result<Vec<QuoteResponse>, JupiterError>
pub async fn get_routes( &self, input_mint: &str, output_mint: &str, amount: u64, slippage_bps: u16, ) -> Result<Vec<QuoteResponse>, JupiterError>
Gets multiple routes for token swap
Sourcepub async fn simple_swap_quote(
&self,
input_mint: &str,
output_mint: &str,
amount: u64,
slippage_bps: Option<u16>,
) -> Result<QuoteResponse, JupiterError>
pub async fn simple_swap_quote( &self, input_mint: &str, output_mint: &str, amount: u64, slippage_bps: Option<u16>, ) -> Result<QuoteResponse, JupiterError>
Simple method to get swap quote
§Example
use jupiter_sdk::JupiterClient;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let client = JupiterClient::new()?;
let input_mint = "So11111111111111111111111111111111111111112";
let output_mint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
let amount = 1000000;
let quote = client.simple_swap_quote(input_mint, output_mint, amount, Some(50)).await?;
Ok(())
}Sourcepub async fn get_token_by_symbol(
&self,
symbol: &str,
) -> Result<Option<TokenInfo>, JupiterError>
pub async fn get_token_by_symbol( &self, symbol: &str, ) -> Result<Option<TokenInfo>, JupiterError>
Finds token by symbol
Sourcepub async fn get_token_by_address(
&self,
address: &str,
) -> Result<Option<TokenInfo>, JupiterError>
pub async fn get_token_by_address( &self, address: &str, ) -> Result<Option<TokenInfo>, JupiterError>
Finds token by address
Sourcepub async fn get_token_price(
&self,
mint_address: &str,
) -> Result<Option<f64>, JupiterError>
pub async fn get_token_price( &self, mint_address: &str, ) -> Result<Option<f64>, JupiterError>
Gets price for a single token
Sourcepub async fn create_swap_transaction(
&self,
quote: QuoteResponse,
user_public_key: &str,
wrap_and_unwrap_sol: Option<bool>,
) -> Result<SwapResponse, JupiterError>
pub async fn create_swap_transaction( &self, quote: QuoteResponse, user_public_key: &str, wrap_and_unwrap_sol: Option<bool>, ) -> Result<SwapResponse, JupiterError>
Creates swap transaction from quote
pub async fn get_quotes_batch( &self, requests: &[QuoteRequest], ) -> Result<Vec<Result<QuoteResponse, JupiterError>>, JupiterError>
pub async fn get_quote_with_retry( &self, request: &QuoteRequest, max_retries: u32, ) -> Result<QuoteResponse, JupiterError>
Sourcepub async fn get_indexed_route_map(
&self,
) -> Result<IndexedRouteMapResponse, JupiterError>
pub async fn get_indexed_route_map( &self, ) -> Result<IndexedRouteMapResponse, JupiterError>
Get Route Map - Used to understand all available transaction paths Gets all token pairs and routing information supported by Jupiter
Sourcepub async fn get_program_ids(&self) -> Result<Vec<String>, JupiterError>
pub async fn get_program_ids(&self) -> Result<Vec<String>, JupiterError>
Get a list of program IDs - used to verify the programs involved in a transaction Get all Solana program IDs involved in a Jupiter exchange
pub async fn health(&self) -> Result<bool, JupiterError>
Sourcepub async fn get_prices_batch(
&self,
token_pairs: &[(&str, &str)],
) -> Result<HashMap<String, f64>, JupiterError>
pub async fn get_prices_batch( &self, token_pairs: &[(&str, &str)], ) -> Result<HashMap<String, f64>, JupiterError>
Batch Price Retrieval - Retrieve prices of multiple tokens at once Efficiently retrieve price information for multiple tokens, reducing the number of API calls.
Sourcepub async fn analyze_routes(
&self,
input_mint: &str,
output_mint: &str,
amount: u64,
max_routes: Option<usize>,
) -> Result<RouteAnalysis, JupiterError>
pub async fn analyze_routes( &self, input_mint: &str, output_mint: &str, amount: u64, max_routes: Option<usize>, ) -> Result<RouteAnalysis, JupiterError>
Advanced Route Analysis - Compare multiple routes and select the optimal one
Sourcepub async fn get_tokens_paginated(
&self,
page: Option<u32>,
page_size: Option<u32>,
) -> Result<Vec<TokenInfo>, JupiterError>
pub async fn get_tokens_paginated( &self, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<TokenInfo>, JupiterError>
Paginated token list - Use pagination when retrieving a large number of tokens Supports paginated retrieval of token lists to avoid loading too much data at once.
Sourcepub async fn get_tokens_by_tag(
&self,
tag: &str,
) -> Result<Vec<TokenInfo>, JupiterError>
pub async fn get_tokens_by_tag( &self, tag: &str, ) -> Result<Vec<TokenInfo>, JupiterError>
Filter tokens by tag - Get tokens categorized by purpose Filter tokens by tag (e.g., stablecoin, defi, etc.)
Sourcepub async fn estimate_transaction_fee(
&self,
quote: &QuoteResponse,
priority_fee: Option<u64>,
) -> Result<u64, JupiterError>
pub async fn estimate_transaction_fee( &self, quote: &QuoteResponse, priority_fee: Option<u64>, ) -> Result<u64, JupiterError>
Calculate transaction fees - Estimate transaction execution costs Estimate transaction fees based on transaction complexity and current network status
Sourcepub async fn get_swap_transaction_with_retry(
&self,
request: &SwapRequest,
config: &RetryConfig,
) -> Result<SwapResponse, JupiterError>
pub async fn get_swap_transaction_with_retry( &self, request: &SwapRequest, config: &RetryConfig, ) -> Result<SwapResponse, JupiterError>
Exchange transaction creation with retries
Auto Trait Implementations§
impl Freeze for JupiterClient
impl !RefUnwindSafe for JupiterClient
impl Send for JupiterClient
impl Sync for JupiterClient
impl Unpin for JupiterClient
impl !UnwindSafe for JupiterClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more