Dedicated Nodes can optionally use the Jupiter Swap API plug-in. When enabled, this allows you to build transactions and get on-chain prices for any token on major DEXs with slippage protection. Select your preferred Swap API plug-in when you purchase a dedicated node to use it. You then interact with it via HTTP requests or using an SDK.
Note: Including a Swap API on your dedicated node can impact performance. We recommend only enabling it if your application requires real-time swap capabilities.
Swap API Options
Jupiter Swap API
Using the SDK
Our Jupiter Swap API integration uses the official Jupiter API package available at https://www.npmjs.com/package/@jup-ag/api. This package provides simple methods to retrieve quotes and execute swap transactions.
Connecting to the Jupiter Swap API
The Jupiter Swap API is accessible through your dedicated node at the base URL of <RPC_URL>/api/jup/
. Use this base URL with the endpoints described below.
Authorization
Include your RPC token in the authorization header of your POST requests. For example, if your dedicated node RPC URL is https://raging-river.hellomoon.io/hf0e87h7ewh98, set an authorization header like { Authorization: "Bearer hf0e87h7ewh98" }
on all routes.
Get a quote
You can retrieve a quote for a token swap by using the quoteGet
method from the Jupiter SDK.
Example Using the SDK
import { createJupiterApiClient } from "@jup-ag/api";
import { inspect } from "util";
const main = async () => {
const jupiter = createJupiterApiClient({
basePath: "https://raging-river.hellomoon.io/api/jup",
headers: {
Authorization: "Bearer hf0e87h7ewh98",
},
});
const quote = await jupiter.quoteGet({
inputMint: "So11111111111111111111111111111111111111112", // SOL
outputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
amount: 100000000, // 0.1 SOL (100000000 lamports)
slippageBps: 100, // 1% slippage tolerance
});
console.log(inspect(quote));
};
if (require.main === module) {
main().catch(console.error);
}
Response
This will return a response in the following format:
{
inputMint: 'So11111111111111111111111111111111111111112',
inAmount: '100000000',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
outAmount: '13778298',
otherAmountThreshold: '13640516',
swapMode: 'ExactIn',
slippageBps: 100,
platformFee: undefined,
priceImpactPct: '0',
routePlan: [
{ swapInfo: [Object], percent: 100 },
{ swapInfo: [Object], percent: 100 }
],
contextSlot: 329349748,
timeTaken: 0.002020169
}
Create a swap transaction
You can create a swap transaction by using the swapPost
method from the Jupiter SDK:
import { createJupiterApiClient } from "@jup-ag/api";
import { Connection, Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";
import { inspect } from "util";
// Replace with your actual private key
const BS58_PRIVATE_KEY = "YOUR_PRIVATE_KEY";
const main = async () => {
// Initialize Jupiter API client
const jupiter = createJupiterApiClient({
basePath: "https://raging-river.hellomoon.io/api/jup",
headers: {
Authorization: "Bearer hf0e87h7ewh98",
},
});
// Step 1: Get a quote
const quote = await jupiter.quoteGet({
inputMint: "So11111111111111111111111111111111111111112", // SOL
outputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
amount: 100000000, // 0.1 SOL (100000000 lamports)
slippageBps: 100, // 1% slippage tolerance
});
console.log("Quote obtained:", inspect(quote, { depth: null }));
// Step 2: Create a wallet for transaction (replace with your actual wallet)
// Note: In production, use a more secure way to handle private keys
const privateKey = bs58.decode(BS58_PRIVATE_KEY);
const wallet = Keypair.fromSecretKey(privateKey);
// Step 3: Connect to Solana
const connection = new Connection(
"https://raging-river.hellomoon.io/hf0e87h7ewh98",
"confirmed",
);
// Step 4: Create the swap transaction
const swapTransaction = await jupiter.swapPost({
swapRequest: {
quoteResponse: quote,
userPublicKey: wallet.publicKey.toString(),
},
});
console.log(
"Swap transaction created:",
inspect(swapTransaction, { depth: null }),
);
// Step 5: Deserialize the transaction
const swapTransactionBuf = Buffer.from(
swapTransaction.swapTransaction,
"base64",
);
const transaction = VersionedTransaction.deserialize(swapTransactionBuf);
// Step 6: Sign the transaction
transaction.sign([wallet]);
// Step 7: Execute the transaction
const signature = await connection.sendTransaction(transaction);
console.log("Transaction submitted:", signature);
// Step 8: Confirm the transaction
const confirmation = await connection.confirmTransaction(
signature,
"confirmed",
);
console.log("Transaction confirmed:", confirmation);
};
if (require.main === module) {
main().catch(console.error);
}
Response
The output from this sample will look something like the following:
Quote obtained: {
inputMint: 'So11111111111111111111111111111111111111112',
inAmount: '100000000',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
outAmount: '13949101',
otherAmountThreshold: '13809610',
swapMode: 'ExactIn',
slippageBps: 100,
platformFee: undefined,
priceImpactPct: '0',
routePlan: [
{
swapInfo: {
ammKey: '71GHcjkwmtM7HSWBuqzjEp96prcNNwu1wpUywXiytREU',
label: 'Lifinity V2',
inputMint: 'So11111111111111111111111111111111111111112',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
inAmount: '100000000',
outAmount: '13949101',
feeAmount: '0',
feeMint: 'So11111111111111111111111111111111111111112'
},
percent: 100
}
],
contextSlot: 329537341,
timeTaken: 0.002056727
}
Swap transaction created: {
swapTransaction: '<redacted>',
lastValidBlockHeight: 307787472,
prioritizationFeeLamports: 99999
}
Transaction submitted: <redacted>
Transaction confirmed: { context: { slot: 329537344 }, value: { err: null } }