For the complete documentation index, see llms.txt. This page is also available as Markdown.

GetSwapPrice

Get a price-only quote without transaction data.

Returns a price quote without instructions or transaction data. Use it when you need to display prices in a UI without the overhead of building executable transactions — lighter weight than NewSwapQuoteStream.

This is a one-shot request, not a stream. The server finds the best direct route and uses the simulated output to determine the price.

Request

struct SwapPriceRequest {
  /// Address of the input mint of the swap.
  inputMint: Pubkey,
  /// Address of the desired output token for the swap.
  outputMint: Pubkey,
  /// Raw number of tokens to swap, not scaled by decimals.
  amount: u64,
  /// If set, constrain quotes to the given set of DEXes.
  dexes: Option<Vec<String>>,
  /// If set, exclude the following DEXes when determining routes.
  excludeDexes: Option<Vec<String>>,
}
interface SwapPriceRequest {
  // Address of the input mint.
  inputMint: Pubkey;
  // Address of the output mint.
  outputMint: Pubkey;
  // Raw number of tokens to swap. Use BigInt.
  amount: number | bigint;
  // If set, constrain to these DEXes.
  dexes?: string[];
  // If set, exclude these DEXes.
  excludeDexes?: string[];
}

Response

struct SwapPrice {
  /// Identifier for this price quote.
  id: String,
  /// Address of the input mint.
  inputMint: Pubkey,
  /// Address of the output mint.
  outputMint: Pubkey,
  /// Amount that was used for the price.
  amountIn: u64,
  /// The amount out of the best simulated quote.
  amountOut: u64,
}
interface SwapPrice {
  // Identifier for this price quote.
  id: string;
  // Address of the input mint.
  inputMint: Pubkey;
  // Address of the output mint.
  outputMint: Pubkey;
  // Amount used for pricing.
  amountIn: number | bigint;
  // Best simulated output amount.
  amountOut: number | bigint;
}

The response does not include instructions, addressLookupTables, or any transaction data. To get executable swap data, use NewSwapQuoteStream or the Gateway Quote Swap endpoint.

Example

See Connection & Negotiation for sendRequest and decodeMessage setup.


Last updated