Swaps with Jupiter
Jupiter aggregates liquidity across Raydium, Orca, Meteora, and other Solana AMMs into a single swap API. Use it when you need best-price routing without maintaining pool graphs yourself.
Search across all documentation pages
Jupiter aggregates liquidity across Raydium, Orca, Meteora, and other Solana AMMs into a single swap API. Use it when you need best-price routing without maintaining pool graphs yourself.
Quick-reference recipe card - copy-paste ready.
const quote = await fetch(
`https://quote-api.jup.ag/v6/quote?inputMint=${inMint}&outputMint=${outMint}&amount=${amount}&slippageBps=50`
).then((r) => r.json());
const swap = await fetch("https://quote-api.jup.ag/v6/swap", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ quoteResponse: quote, userPublicKey: wallet, wrapAndUnwrapSol: true }),
}).then((r) => r.json());When to reach for this:
@solana/kit 7.0.0 signers.import { createSolanaRpc, address, lamports } from "@solana/kit";
import { getBase58Codec } from "@solana/codecs-strings";
const RPC = "https://api.mainnet-beta.solana.com";
const rpc = createSolanaRpc(RPC);
const inputMint = "So11111111111111111111111111111111111111112";
const outputMint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
const amount = "50000000"; // 0.05 SOL
const slippageBps = 50;
const userPublicKey = "YOUR_WALLET_PUBKEY";
const quote = await fetch(
`https://quote-api.jup.ag/v6/quote?inputMint=${inputMint}&outputMint=${outputMint}&amount=${amount}&slippageBps=${slippageBps}`
).then((r) => r.json());
const { swapTransaction } = await fetch("https://quote-api.jup.ag/v6/swap", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
quoteResponse: quote,
userPublicKey,
wrapAndUnwrapSol: true,
dynamicComputeUnitLimit: true,
prioritizationFeeLamports: "auto",
}),
}).then((r) => r.json());
const txBytes = getBase58Codec().decode(swapTransaction);
// Sign txBytes with wallet, send via rpc.sendTransaction(...)
console.log("Expected out:", quote.outAmount);What this demonstrates:
outAmount, priceImpactPct, and routePlan.dynamicComputeUnitLimit and prioritizationFeeLamports tune landing on Agave 4.1.1.| Endpoint | Purpose | Key params |
|---|---|---|
/v6/quote | Price route | inputMint, outputMint, amount, slippageBps |
/v6/swap | Build tx | quoteResponse, userPublicKey |
/v6/swap-instructions | Raw ix list | For custom tx assembly |
// Refresh quote if blockhash ages - quotes expire quickly
const MAX_QUOTE_AGE_MS = 30_000;
const quotedAt = Date.now();
// Re-quote before send if Date.now() - quotedAt > MAX_QUOTE_AGE_MSswap and set a max age window.SlippageToleranceExceeded. Fix: Increase slippageBps or split into smaller swaps.createAta options or pre-create ATA in a setup tx.wrapAndUnwrapSol: true or manage wSOL ATA explicitly.dynamicComputeUnitLimit: true.| Alternative | Use When | Don't Use When |
|---|---|---|
| Direct AMM CPI | You control pool + want minimal deps | You need best price across venues |
| Jupiter swap-instructions | Custom tx with your own ALTs | You want fastest path to a working swap |
| On-chain Jupiter program CPI | Swap inside your Anchor program | You need off-chain route discovery only |
Start at 50 bps (0.5%) for liquid pairs. Raise to 100-300 bps for thin pools or volatile launches.
Yes - CPI into Jupiter's on-chain program with accounts from swap-instructions. Off-chain routing still discovers the path.
Pass prioritizationFeeLamports: "auto" in the swap request, or set an explicit lamport value from your fee oracle.
Use swapMode=ExactOut on the quote endpoint when you need a precise output amount (e.g., repay exact debt).
Quote staleness, account lock contention, or priority fee too low. Re-quote and bump CU/priority fee.
Yes - pass dexes allow/deny lists on the quote API to exclude untrusted venues.
Inspect quote.routePlan - each step shows swapInfo with AMM label, in/out amounts, and pool address.
Heavy server traffic should cache quotes briefly and backoff on HTTP 429. Consider Jupiter paid tiers for production.
Use Surfpool 0.12.0 mainnet fork with funded test wallets, or devnet with known pool mints (limited routes).
Token-2022 mints are supported on many routes but not all pools. Check routePlan token program IDs per leg.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026