JupiterClient

Struct JupiterClient 

Source
pub struct JupiterClient { /* private fields */ }
Expand description

Main client for interacting with Jupiter API

Implementations§

Source§

impl JupiterClient

Source

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();
Source

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();
Source

pub fn from_client(client: Client) -> Result<Self, JupiterError>

reate a client based on an existing client, using the default configuration.

Source

pub fn from_config(config: ClientConfig) -> Result<Self, JupiterError>

create a client using configuration

Source

pub fn with_rate_limit(requests_per_second: u32) -> Result<Self, JupiterError>

create a client with rate limiting

Source

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?;
Source

pub async fn monitor_transactions_batch( &self, signatures: &[String], solana: &Solana, config: Option<TransactionMonitorConfig>, ) -> Result<Vec<TransactionMonitorResult>, JupiterError>

Monitors multiple transactions in batch

Source

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(())
}
Source

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(())
}
Source

pub async fn get_tokens(&self) -> Result<Vec<TokenInfo>, JupiterError>

Gets list of all supported tokens

Source

pub async fn get_price( &self, ids: &[String], ) -> Result<HashMap<String, PriceResponse>, JupiterError>

Gets prices for multiple tokens

Source

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

Source

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(())
}
Source

pub async fn get_token_by_symbol( &self, symbol: &str, ) -> Result<Option<TokenInfo>, JupiterError>

Finds token by symbol

Source

pub async fn get_token_by_address( &self, address: &str, ) -> Result<Option<TokenInfo>, JupiterError>

Finds token by address

Source

pub async fn get_token_price( &self, mint_address: &str, ) -> Result<Option<f64>, JupiterError>

Gets price for a single token

Source

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

Source

pub async fn get_quotes_batch( &self, requests: &[QuoteRequest], ) -> Result<Vec<Result<QuoteResponse, JupiterError>>, JupiterError>

Source

pub async fn get_quote_with_retry( &self, request: &QuoteRequest, max_retries: u32, ) -> Result<QuoteResponse, JupiterError>

Source

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

Source

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

Source

pub async fn health(&self) -> Result<bool, JupiterError>

Source

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.

Source

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

Source

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.

Source

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

Source

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

Source

pub async fn get_swap_transaction_with_retry( &self, request: &SwapRequest, config: &RetryConfig, ) -> Result<SwapResponse, JupiterError>

Exchange transaction creation with retries

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more