/swap-instructions REST API Endpoint - Metis
Please note that this method is available for Free and Paid subscribers of Metis - Jupiter Swap API, along with jupiterapi.com users.
Solana Kit includes the ability to customize RPC methods and transports, allowing you to seamlessly integrate Quicknode Marketplace add-ons into your applications. For more information on how to use Quicknode Marketplace add-ons with Solana Kit, check out these guides: How to Use Quicknode Add-ons using Solana Kit (Part 1) and How to Use Quicknode Add-ons using Solana Kit (Part 2)
GooseFX Gamma API: When using the /quote endpoint with the setting of dexes=Gamma, you should include the query parameter dexes=Gamma when using this endpoint if you want to route directly to the GooseFX Gamma API. This is in addition to setting dexes=Gamma on your initial /quote request.
Paramètres de requête
userPublicKey
chaîne de caractères
OBLIGATOIRE
Chargement...
payer
chaîne de caractères
Chargement...
wrapAndUnwrapSol
booléen
Chargement...
useSharedAccounts
booléen
Chargement...
feeAccount
chaîne de caractères
Chargement...
trackingAccount
chaîne de caractères
Chargement...
computeUnitPriceMicroLamports
entier
Chargement...
prioritizationFeeLamports
objet
Chargement...
priorityLevelWithMaxLamports
objet
Chargement...
priorityLevel
chaîne de caractères
Chargement...
maxLamports
entier
Chargement...
global
booléen
Chargement...
jitoTipLamports
entier
Chargement...
jitoTipLamportsWithPayer
objet
Chargement...
lamports
entier
OBLIGATOIRE
Chargement...
payer
chaîne de caractères
OBLIGATOIRE
Chargement...
asLegacyTransaction
booléen
Chargement...
destinationTokenAccount
chaîne de caractères
Chargement...
nativeDestinationAccount
chaîne de caractères
Chargement...
dynamicComputeUnitLimit
booléen
Chargement...
skipUserAccountsRpcCalls
booléen
Chargement...
dynamicSlippage
booléen
Chargement...
blockhashSlotsToExpiry
entier
Chargement...
quoteResponse
objet
OBLIGATOIRE
Chargement...
inputMint
chaîne de caractères
OBLIGATOIRE
Chargement...
inAmount
chaîne de caractères
OBLIGATOIRE
Chargement...
outputMint
chaîne de caractères
OBLIGATOIRE
Chargement...
outAmount
chaîne de caractères
OBLIGATOIRE
Chargement...
otherAmountThreshold
chaîne de caractères
OBLIGATOIRE
Chargement...
swapMode
chaîne de caractères
OBLIGATOIRE
Chargement...
slippageBps
entier
OBLIGATOIRE
Chargement...
platformFee
objet
Chargement...
montant
chaîne de caractères
Chargement...
feeBps
entier
Chargement...
priceImpactPct
chaîne de caractères
OBLIGATOIRE
Chargement...
routePlan
tableau
OBLIGATOIRE
Chargement...
swapInfo
objet
OBLIGATOIRE
Chargement...
ammKey
chaîne de caractères
OBLIGATOIRE
Chargement...
étiquette
chaîne de caractères
Chargement...
inputMint
chaîne de caractères
OBLIGATOIRE
Chargement...
outputMint
chaîne de caractères
OBLIGATOIRE
Chargement...
inAmount
chaîne de caractères
OBLIGATOIRE
Chargement...
outAmount
chaîne de caractères
OBLIGATOIRE
Chargement...
feeAmount
chaîne de caractères
OBLIGATOIRE
Chargement...
feeMint
chaîne de caractères
OBLIGATOIRE
Chargement...
percent
entier
OBLIGATOIRE
Chargement...
bps
entier
Chargement...
instructionVersion
chaîne de caractères
Chargement...
contextSlot
entier
Chargement...
timeTaken
entier
Chargement...
Renvoie
tokenLedgerInstruction
objet
Chargement...
programId
chaîne de caractères
Chargement...
accounts
tableau
Chargement...
pubkey
chaîne de caractères
Chargement...
isSigner
booléen
Chargement...
isWritable
booléen
Chargement...
données
chaîne de caractères
Chargement...
computeBudgetInstructions
tableau
Chargement...
programId
chaîne de caractères
Chargement...
accounts
tableau
Chargement...
pubkey
chaîne de caractères
Chargement...
isSigner
booléen
Chargement...
isWritable
booléen
Chargement...
données
chaîne de caractères
Chargement...
setupInstructions
tableau
Chargement...
programId
chaîne de caractères
Chargement...
accounts
tableau
Chargement...
pubkey
chaîne de caractères
Chargement...
isSigner
booléen
Chargement...
isWritable
booléen
Chargement...
données
chaîne de caractères
Chargement...
swapInstruction
objet
Chargement...
programId
chaîne de caractères
Chargement...
accounts
tableau
Chargement...
pubkey
chaîne de caractères
Chargement...
isSigner
booléen
Chargement...
isWritable
booléen
Chargement...
données
chaîne de caractères
Chargement...
cleanupInstruction
objet
Chargement...
programId
chaîne de caractères
Chargement...
accounts
tableau
Chargement...
pubkey
chaîne de caractères
Chargement...
isSigner
booléen
Chargement...
isWritable
booléen
Chargement...
données
chaîne de caractères
Chargement...
otherInstructions
tableau
Chargement...
addressLookupTableAddresses
tableau
Chargement...
prioritizationFeeLamports
entier
Chargement...
Requête
1curl --location 'https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions' \2--header 'Content-Type: application/json' \3--data '{4"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",5"quoteResponse": {6"inputMint": "So11111111111111111111111111111111111111112",7"inAmount": "1000000000",8"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",9"outAmount": "47737119",10"otherAmountThreshold": "47498434",11"swapMode": "ExactIn",12"slippageBps": 50,13"platformFee": null,14"priceImpactPct": "0",15"routePlan": [16{17"swapInfo": {18"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",19"label": "Phoenix",20"inputMint": "So11111111111111111111111111111111111111112",21"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",22"inAmount": "200000000",23"outAmount": "9546224",24"feeAmount": "4776",25"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"26},27"percent": 2028},29{30"swapInfo": {31"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",32"label": "Meteora DLMM",33"inputMint": "So11111111111111111111111111111111111111112",34"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",35"inAmount": "800000000",36"outAmount": "59167218",37"feeAmount": "240003",38"feeMint": "So11111111111111111111111111111111111111112"39},40"percent": 8041},42{43"swapInfo": {44"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",45"label": "Whirlpool",46"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",47"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",48"inAmount": "59167218",49"outAmount": "148627676",50"feeAmount": "0",51"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"52},53"percent": 10054},55{56"swapInfo": {57"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",58"label": "Phoenix",59"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",60"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",61"inAmount": "148627676",62"outAmount": "38190895",63"feeAmount": "19105",64"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"65},66"percent": 10067}68],69"contextSlot": 257193413,70"timeTaken": 0.41189167771}72}'
1curl --location 'https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions' \2--header 'Content-Type: application/json' \3--data '{4"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",5"quoteResponse": {6"inputMint": "So11111111111111111111111111111111111111112",7"inAmount": "1000000000",8"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",9"outAmount": "47737119",10"otherAmountThreshold": "47498434",11"swapMode": "ExactIn",12"slippageBps": 50,13"platformFee": null,14"priceImpactPct": "0",15"routePlan": [16{17"swapInfo": {18"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",19"label": "Phoenix",20"inputMint": "So11111111111111111111111111111111111111112",21"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",22"inAmount": "200000000",23"outAmount": "9546224",24"feeAmount": "4776",25"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"26},27"percent": 2028},29{30"swapInfo": {31"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",32"label": "Meteora DLMM",33"inputMint": "So11111111111111111111111111111111111111112",34"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",35"inAmount": "800000000",36"outAmount": "59167218",37"feeAmount": "240003",38"feeMint": "So11111111111111111111111111111111111111112"39},40"percent": 8041},42{43"swapInfo": {44"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",45"label": "Whirlpool",46"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",47"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",48"inAmount": "59167218",49"outAmount": "148627676",50"feeAmount": "0",51"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"52},53"percent": 10054},55{56"swapInfo": {57"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",58"label": "Phoenix",59"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",60"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",61"inAmount": "148627676",62"outAmount": "38190895",63"feeAmount": "19105",64"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"65},66"percent": 10067}68],69"contextSlot": 257193413,70"timeTaken": 0.41189167771}72}'
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",14"quoteResponse": {15"inputMint": "So11111111111111111111111111111111111111112",16"inAmount": "1000000000",17"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",18"outAmount": "47737119",19"otherAmountThreshold": "47498434",20"swapMode": "ExactIn",21"slippageBps": 50,22"platformFee": nil,23"priceImpactPct": "0",24"routePlan": [25{26"swapInfo": {27"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",28"label": "Phoenix",29"inputMint": "So11111111111111111111111111111111111111112",30"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",31"inAmount": "200000000",32"outAmount": "9546224",33"feeAmount": "4776",34"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"35},36"percent": 2037},38{39"swapInfo": {40"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",41"label": "Meteora DLMM",42"inputMint": "So11111111111111111111111111111111111111112",43"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",44"inAmount": "800000000",45"outAmount": "59167218",46"feeAmount": "240003",47"feeMint": "So11111111111111111111111111111111111111112"48},49"percent": 8050},51{52"swapInfo": {53"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",54"label": "Whirlpool",55"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",56"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",57"inAmount": "59167218",58"outAmount": "148627676",59"feeAmount": "0",60"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"61},62"percent": 10063},64{65"swapInfo": {66"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",67"label": "Phoenix",68"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",69"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",70"inAmount": "148627676",71"outAmount": "38190895",72"feeAmount": "19105",73"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"74},75"percent": 10076}77],78"contextSlot": 257193413,79"timeTaken": 0.41189167780}81})8283response = https.request(request)84puts response.read_body85
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",14"quoteResponse": {15"inputMint": "So11111111111111111111111111111111111111112",16"inAmount": "1000000000",17"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",18"outAmount": "47737119",19"otherAmountThreshold": "47498434",20"swapMode": "ExactIn",21"slippageBps": 50,22"platformFee": nil,23"priceImpactPct": "0",24"routePlan": [25{26"swapInfo": {27"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",28"label": "Phoenix",29"inputMint": "So11111111111111111111111111111111111111112",30"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",31"inAmount": "200000000",32"outAmount": "9546224",33"feeAmount": "4776",34"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"35},36"percent": 2037},38{39"swapInfo": {40"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",41"label": "Meteora DLMM",42"inputMint": "So11111111111111111111111111111111111111112",43"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",44"inAmount": "800000000",45"outAmount": "59167218",46"feeAmount": "240003",47"feeMint": "So11111111111111111111111111111111111111112"48},49"percent": 8050},51{52"swapInfo": {53"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",54"label": "Whirlpool",55"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",56"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",57"inAmount": "59167218",58"outAmount": "148627676",59"feeAmount": "0",60"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"61},62"percent": 10063},64{65"swapInfo": {66"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",67"label": "Phoenix",68"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",69"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",70"inAmount": "148627676",71"outAmount": "38190895",72"feeAmount": "19105",73"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"74},75"percent": 10076}77],78"contextSlot": 257193413,79"timeTaken": 0.41189167780}81})8283response = https.request(request)84puts response.read_body85
1const myHeaders = new Headers();2mesEnTêtes.ajouter("Content-Type", "application/json");34const brut = JSON.stringify({5"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",6"quoteResponse": {7"inputMint": "So11111111111111111111111111111111111111112",8"inAmount": "1000000000",9"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",10"outAmount": "47737119",11"otherAmountThreshold": "47498434",12"swapMode": "ExactIn",13"slippageBps": 50,14"platformFee": null,15"priceImpactPct": "0",16"routePlan": [17{18"swapInfo": {19"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",20"label": "Phoenix",21"inputMint": "So11111111111111111111111111111111111111112",22"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",23"inAmount": "200000000",24"outAmount": "9546224",25"feeAmount": "4776",26"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"27},28"percent": 2029},30{31"swapInfo": {32"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",33"label": "Meteora DLMM",34"inputMint": "So11111111111111111111111111111111111111112",35"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",36"inAmount": "800000000",37"outAmount": "59167218",38"feeAmount": "240003",39"feeMint": "So11111111111111111111111111111111111111112"40},41"percent": 8042},43{44"swapInfo": {45"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",46"label": "Whirlpool",47"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",48"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",49"inAmount": "59167218",50"outAmount": "148627676",51"feeAmount": "0",52"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"53},54"percent": 10055},56{57"swapInfo": {58"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",59"label": "Phoenix",60"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",61"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",62"inAmount": "148627676",63"outAmount": "38190895",64"feeAmount": "19105",65"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"66},67"percent": 10068}69],70"contextSlot": 257193413,71"timeTaken": 0.41189167772}73});7475const requestOptions = {76méthode: « POST »,77headers: myHeaders,78body: raw,79redirect: "follow"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions", requestOptions)83.then((response) => response.text())84.then((result) => console.log(result))85.catch((error) => console.error(error));
1const myHeaders = new Headers();2mesEnTêtes.ajouter("Content-Type", "application/json");34const brut = JSON.stringify({5"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",6"quoteResponse": {7"inputMint": "So11111111111111111111111111111111111111112",8"inAmount": "1000000000",9"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",10"outAmount": "47737119",11"otherAmountThreshold": "47498434",12"swapMode": "ExactIn",13"slippageBps": 50,14"platformFee": null,15"priceImpactPct": "0",16"routePlan": [17{18"swapInfo": {19"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",20"label": "Phoenix",21"inputMint": "So11111111111111111111111111111111111111112",22"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",23"inAmount": "200000000",24"outAmount": "9546224",25"feeAmount": "4776",26"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"27},28"percent": 2029},30{31"swapInfo": {32"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",33"label": "Meteora DLMM",34"inputMint": "So11111111111111111111111111111111111111112",35"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",36"inAmount": "800000000",37"outAmount": "59167218",38"feeAmount": "240003",39"feeMint": "So11111111111111111111111111111111111111112"40},41"percent": 8042},43{44"swapInfo": {45"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",46"label": "Whirlpool",47"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",48"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",49"inAmount": "59167218",50"outAmount": "148627676",51"feeAmount": "0",52"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"53},54"percent": 10055},56{57"swapInfo": {58"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",59"label": "Phoenix",60"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",61"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",62"inAmount": "148627676",63"outAmount": "38190895",64"feeAmount": "19105",65"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"66},67"percent": 10068}69],70"contextSlot": 257193413,71"timeTaken": 0.41189167772}73});7475const requestOptions = {76méthode: « POST »,77headers: myHeaders,78body: raw,79redirect: "follow"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions", requestOptions)83.then((response) => response.text())84.then((result) => console.log(result))85.catch((error) => console.error(error));
1import { QuoteGetRequest, QuoteResponse, createJupiterApiClient, ResponseError } from '@jup-ag/api';2import { Keypair } from '@solana/web3.js';34const ENDPOINT = `https://docs-demo.solana-mainnet.quiknode.pro/`;5const CONFIG = {6basePath: ENDPOINT7};89const quoteRequest: QuoteGetRequest = {10inputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",11outputMint: "So11111111111111111111111111111111111111112",12amount: 10.03 * 1e6,13}1415async function main(): Promise<void> {16const jupiterApi = createJupiterApiClient(CONFIG);17const wallet = Keypair.generate();1819essayer {20// 1. Retrieve a Swap Quote21const quote: QuoteResponse | null = await jupiterApi.quoteGet(quoteRequest);22if (!quote) {23throw new Error('No quote found');24}2526// 2. Get Serialized Swap Transaction27const swapResult = await jupiterApi.swapInstructionsPost({28swapRequest: {29//@ts-ignore30quoteResponse: quote,31userPublicKey: wallet.publicKey.toBase58(),32},33});34if (!swapResult) {35throw new Error('No swap result found');36}37console.log(swapResult);38} catch (error) {39if (error instanceof ResponseError) {40console.log(await error.response.json());41}42else {43console.error(error);44}45}46}4748main();
1import { QuoteGetRequest, QuoteResponse, createJupiterApiClient, ResponseError } from '@jup-ag/api';2import { Keypair } from '@solana/web3.js';34const ENDPOINT = `https://docs-demo.solana-mainnet.quiknode.pro/`;5const CONFIG = {6basePath: ENDPOINT7};89const quoteRequest: QuoteGetRequest = {10inputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",11outputMint: "So11111111111111111111111111111111111111112",12amount: 10.03 * 1e6,13}1415async function main(): Promise<void> {16const jupiterApi = createJupiterApiClient(CONFIG);17const wallet = Keypair.generate();1819essayer {20// 1. Retrieve a Swap Quote21const quote: QuoteResponse | null = await jupiterApi.quoteGet(quoteRequest);22if (!quote) {23throw new Error('No quote found');24}2526// 2. Get Serialized Swap Transaction27const swapResult = await jupiterApi.swapInstructionsPost({28swapRequest: {29//@ts-ignore30quoteResponse: quote,31userPublicKey: wallet.publicKey.toBase58(),32},33});34if (!swapResult) {35throw new Error('No swap result found');36}37console.log(swapResult);38} catch (error) {39if (error instanceof ResponseError) {40console.log(await error.response.json());41}42else {43console.error(error);44}45}46}4748main();
1#[tokio::main]2async fn main() -> Result<(), Box<dyn std::error::Error>> {3let client = reqwest::Client::builder()4.build()?;56let mut headers = reqwest::header::HeaderMap::new();7headers.insert("Content-Type", "application/json".parse()?);89let data = r#"{10"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",11"quoteResponse": {12"inputMint": "So11111111111111111111111111111111111111112",13"inAmount": "1000000000",14"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",15"outAmount": "47737119",16"otherAmountThreshold": "47498434",17"swapMode": "ExactIn",18"slippageBps": 50,19"platformFee": null,20"priceImpactPct": "0",21"routePlan": [22{23"swapInfo": {24"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",25"label": "Phoenix",26"inputMint": "So11111111111111111111111111111111111111112",27"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",28"inAmount": "200000000",29"outAmount": "9546224",30"feeAmount": "4776",31"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"32},33"percent": 2034},35{36"swapInfo": {37"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",38"label": "Meteora DLMM",39"inputMint": "So11111111111111111111111111111111111111112",40"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",41"inAmount": "800000000",42"outAmount": "59167218",43"feeAmount": "240003",44"feeMint": "So11111111111111111111111111111111111111112"45},46"percent": 8047},48{49"swapInfo": {50"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",51"label": "Whirlpool",52"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",53"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",54"inAmount": "59167218",55"outAmount": "148627676",56"feeAmount": "0",57"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"58},59"percent": 10060},61{62"swapInfo": {63"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",64"label": "Phoenix",65"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",66"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",67"inAmount": "148627676",68"outAmount": "38190895",69"feeAmount": "19105",70"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"71},72"percent": 10073}74],75"contextSlot": 257193413,76"timeTaken": 0.41189167777}78}"#;7980let json: serde_json::Value = serde_json::from_str(&data)?;8182let request = client.request(reqwest::Method::POST, "https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")83.headers(headers)84.json(&json);8586let response = request.send().await?;87let body = response.text().await?;8889println!("{}", body);9091Ok(())92}
1#[tokio::main]2async fn main() -> Result<(), Box<dyn std::error::Error>> {3let client = reqwest::Client::builder()4.build()?;56let mut headers = reqwest::header::HeaderMap::new();7headers.insert("Content-Type", "application/json".parse()?);89let data = r#"{10"userPublicKey": "3gqQQT8KS6sDLUzHGbBDweg5bT1g443eMSDkKgwGzRdM",11"quoteResponse": {12"inputMint": "So11111111111111111111111111111111111111112",13"inAmount": "1000000000",14"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",15"outAmount": "47737119",16"otherAmountThreshold": "47498434",17"swapMode": "ExactIn",18"slippageBps": 50,19"platformFee": null,20"priceImpactPct": "0",21"routePlan": [22{23"swapInfo": {24"ammKey": "BKLhZ5NrFhCjViC4wyAMXBNsJFHbFfYujo3TtUmBxTH3",25"label": "Phoenix",26"inputMint": "So11111111111111111111111111111111111111112",27"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",28"inAmount": "200000000",29"outAmount": "9546224",30"feeAmount": "4776",31"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"32},33"percent": 2034},35{36"swapInfo": {37"ammKey": "G7ixPyiyNeggVf1VanSetFMNbVuVCPtimJmd9axfQqng",38"label": "Meteora DLMM",39"inputMint": "So11111111111111111111111111111111111111112",40"outputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",41"inAmount": "800000000",42"outAmount": "59167218",43"feeAmount": "240003",44"feeMint": "So11111111111111111111111111111111111111112"45},46"percent": 8047},48{49"swapInfo": {50"ammKey": "BCuk3J7Djjn6WYzSBWrHyGM2cgpUeBBHQtxskgiqyv7p",51"label": "Whirlpool",52"inputMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4",53"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",54"inAmount": "59167218",55"outAmount": "148627676",56"feeAmount": "0",57"feeMint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"58},59"percent": 10060},61{62"swapInfo": {63"ammKey": "6ojSigXF7nDPyhFRgmn3V9ywhYseKF9J32ZrranMGVSX",64"label": "Phoenix",65"inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",66"outputMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",67"inAmount": "148627676",68"outAmount": "38190895",69"feeAmount": "19105",70"feeMint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"71},72"percent": 10073}74],75"contextSlot": 257193413,76"timeTaken": 0.41189167777}78}"#;7980let json: serde_json::Value = serde_json::from_str(&data)?;8182let request = client.request(reqwest::Method::POST, "https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")83.headers(headers)84.json(&json);8586let response = request.send().await?;87let body = response.text().await?;8889println!("{}", body);9091Ok(())92}
Vous n'avez pas encore de compte ?
Créez votre endpoint Quicknode en quelques secondes et commencez à développer
Commencez gratuitement