/swap 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.
Parâmetros de consulta
userPublicKey
cadeia de caracteres
OBRIGATÓRIO
A carregar...
payer
cadeia de caracteres
A carregar...
wrapAndUnwrapSol
booleano
A carregar...
useSharedAccounts
booleano
A carregar...
feeAccount
cadeia de caracteres
A carregar...
trackingAccount
cadeia de caracteres
A carregar...
computeUnitPriceMicroLamports
número inteiro
A carregar...
prioritizationFeeLamports
objeto
A carregar...
priorityLevelWithMaxLamports
objeto
A carregar...
priorityLevel
cadeia de caracteres
A carregar...
maxLamports
número inteiro
A carregar...
global
booleano
A carregar...
jitoTipLamports
número inteiro
A carregar...
jitoTipLamportsWithPayer
objeto
A carregar...
lamports
número inteiro
OBRIGATÓRIO
A carregar...
payer
cadeia de caracteres
OBRIGATÓRIO
A carregar...
asLegacyTransaction
booleano
A carregar...
destinationTokenAccount
cadeia de caracteres
A carregar...
nativeDestinationAccount
cadeia de caracteres
A carregar...
dynamicComputeUnitLimit
booleano
A carregar...
skipUserAccountsRpcCalls
booleano
A carregar...
dynamicSlippage
booleano
A carregar...
blockhashSlotsToExpiry
número inteiro
A carregar...
quoteResponse
objeto
OBRIGATÓRIO
A carregar...
inputMint
cadeia de caracteres
OBRIGATÓRIO
A carregar...
inAmount
cadeia de caracteres
OBRIGATÓRIO
A carregar...
outputMint
cadeia de caracteres
OBRIGATÓRIO
A carregar...
outAmount
cadeia de caracteres
OBRIGATÓRIO
A carregar...
otherAmountThreshold
cadeia de caracteres
OBRIGATÓRIO
A carregar...
swapMode
cadeia de caracteres
OBRIGATÓRIO
A carregar...
slippageBps
número inteiro
OBRIGATÓRIO
A carregar...
platformFee
objeto
A carregar...
montante
cadeia de caracteres
A carregar...
feeBps
número inteiro
A carregar...
priceImpactPct
cadeia de caracteres
OBRIGATÓRIO
A carregar...
routePlan
matriz
OBRIGATÓRIO
A carregar...
swapInfo
objeto
OBRIGATÓRIO
A carregar...
ammKey
cadeia de caracteres
OBRIGATÓRIO
A carregar...
rótulo
cadeia de caracteres
A carregar...
inputMint
cadeia de caracteres
OBRIGATÓRIO
A carregar...
outputMint
cadeia de caracteres
OBRIGATÓRIO
A carregar...
inAmount
cadeia de caracteres
OBRIGATÓRIO
A carregar...
outAmount
cadeia de caracteres
OBRIGATÓRIO
A carregar...
feeAmount
cadeia de caracteres
OBRIGATÓRIO
A carregar...
feeMint
cadeia de caracteres
OBRIGATÓRIO
A carregar...
percent
número inteiro
OBRIGATÓRIO
A carregar...
bps
número inteiro
A carregar...
instructionVersion
cadeia de caracteres
A carregar...
contextSlot
número inteiro
A carregar...
timeTaken
número inteiro
A carregar...
Devoluções
swapTransaction
cadeia de caracteres
A carregar...
lastValidBlockHeight
número inteiro
A carregar...
prioritizationFeeLamports
número inteiro
A carregar...
Pedido
1curl --location 'https://docs-demo.solana-mainnet.quiknode.pro/swap' \2--cabeçalho 'Content-Type: application/json' \3--dados '{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' \2--cabeçalho 'Content-Type: application/json' \3--dados '{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}'
1exigir "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap")67https = Net::HTTP.novo(url.host, url.porta)8https.use_ssl = true910pedido = Líquido::HTTP::POST.novo(url)11pedido["Content-Type"] = "application/json"12pedido.corpo = 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})8283resposta = https.pedido(pedido)84insere a resposta.read_body85
1exigir "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap")67https = Net::HTTP.novo(url.host, url.porta)8https.use_ssl = true910pedido = Líquido::HTTP::POST.novo(url)11pedido["Content-Type"] = "application/json"12pedido.corpo = 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})8283resposta = https.pedido(pedido)84insere a resposta.read_body85
1const myHeaders = new Headers();2myHeaders.acrescentar("Content-Type", "application/json");34const raw = 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étodo: "POST",77cabeçalhos: myHeaders,78corpo: raw,79redirecionar: "seguir"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap", requestOptions)83.então((resposta) => resposta.texto())84.então((resultado) => console.log(resultado))85.catch((erro) => console.erro(erro));
1const myHeaders = new Headers();2myHeaders.acrescentar("Content-Type", "application/json");34const raw = 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étodo: "POST",77cabeçalhos: myHeaders,78corpo: raw,79redirecionar: "seguir"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap", requestOptions)83.então((resposta) => resposta.texto())84.então((resultado) => console.log(resultado))85.catch((erro) => console.erro(erro));
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/* slippageBps: 100,14swapMode: "ExactIn", */15}1617async function main(): Promise<void> {18const jupiterApi = createJupiterApiClient(CONFIG);19const wallet = Keypair.generate();2021try {22// 1. Retrieve a Swap Quote23const quote: QuoteResponse | null = await jupiterApi.quoteGet(quoteRequest);24if (!quote) {25throw new Error('No quote found');26}2728// 2. Get Serialized Swap Transaction29const swapResult = await jupiterApi.swapPost({30swapRequest: {31//@ts-ignore32quoteResponse: quote,33userPublicKey: wallet.publicKey.toBase58(),34},35});36if (!swapResult) {37throw new Error('No swap result found');38}39console.log(swapResult);40} catch (error) {41if (error instanceof ResponseError) {42console.log(await error.response.json());43}44else {45console.error(error);46}47}48}4950principal();
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/* slippageBps: 100,14swapMode: "ExactIn", */15}1617async function main(): Promise<void> {18const jupiterApi = createJupiterApiClient(CONFIG);19const wallet = Keypair.generate();2021try {22// 1. Retrieve a Swap Quote23const quote: QuoteResponse | null = await jupiterApi.quoteGet(quoteRequest);24if (!quote) {25throw new Error('No quote found');26}2728// 2. Get Serialized Swap Transaction29const swapResult = await jupiterApi.swapPost({30swapRequest: {31//@ts-ignore32quoteResponse: quote,33userPublicKey: wallet.publicKey.toBase58(),34},35});36if (!swapResult) {37throw new Error('No swap result found');38}39console.log(swapResult);40} catch (error) {41if (error instanceof ResponseError) {42console.log(await error.response.json());43}44else {45console.error(error);46}47}48}4950principal();
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")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")83.headers(headers)84.json(&json);8586let response = request.send().await?;87let body = response.text().await?;8889println!("{}", body);9091Ok(())92}
Ainda não tem uma conta?
Crie o seu ponto de extremidade Quicknode em segundos e comece a desenvolver
Comece gratuitamente