/swap-instructions REST API Endpoint - Swap API
Please note that this method is available for Free and Paid subscribers of Swap API, along with jupiterapi.com users.
Solana Kit includes the ability to customize RPC methods and transports, allowing you to seamlessly integrate Quicknode add-ons into your applications. For more information on how to use Quicknode 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
Carregando...
payer
cadeia de caracteres
Carregando...
wrapAndUnwrapSol
booleano
Carregando...
useSharedAccounts
booleano
Carregando...
feeAccount
cadeia de caracteres
Carregando...
trackingAccount
cadeia de caracteres
Carregando...
computeUnitPriceMicroLamports
número inteiro
Carregando...
prioritizationFeeLamports
objeto
Carregando...
priorityLevelWithMaxLamports
objeto
Carregando...
priorityLevel
cadeia de caracteres
Carregando...
maxLamports
número inteiro
Carregando...
global
booleano
Carregando...
jitoTipLamports
número inteiro
Carregando...
jitoTipLamportsWithPayer
objeto
Carregando...
lamports
número inteiro
OBRIGATÓRIO
Carregando...
payer
cadeia de caracteres
OBRIGATÓRIO
Carregando...
asLegacyTransaction
booleano
Carregando...
destinationTokenAccount
cadeia de caracteres
Carregando...
nativeDestinationAccount
cadeia de caracteres
Carregando...
dynamicComputeUnitLimit
booleano
Carregando...
skipUserAccountsRpcCalls
booleano
Carregando...
dynamicSlippage
booleano
Carregando...
blockhashSlotsToExpiry
número inteiro
Carregando...
quoteResponse
objeto
OBRIGATÓRIO
Carregando...
inputMint
cadeia de caracteres
OBRIGATÓRIO
Carregando...
inAmount
cadeia de caracteres
OBRIGATÓRIO
Carregando...
outputMint
cadeia de caracteres
OBRIGATÓRIO
Carregando...
outAmount
cadeia de caracteres
OBRIGATÓRIO
Carregando...
otherAmountThreshold
cadeia de caracteres
OBRIGATÓRIO
Carregando...
swapMode
cadeia de caracteres
OBRIGATÓRIO
Carregando...
slippageBps
número inteiro
OBRIGATÓRIO
Carregando...
platformFee
objeto
Carregando...
quantia
cadeia de caracteres
Carregando...
feeBps
número inteiro
Carregando...
priceImpactPct
cadeia de caracteres
OBRIGATÓRIO
Carregando...
routePlan
matriz
OBRIGATÓRIO
Carregando...
swapInfo
objeto
OBRIGATÓRIO
Carregando...
ammKey
cadeia de caracteres
OBRIGATÓRIO
Carregando...
etiqueta
cadeia de caracteres
Carregando...
inputMint
cadeia de caracteres
OBRIGATÓRIO
Carregando...
outputMint
cadeia de caracteres
OBRIGATÓRIO
Carregando...
inAmount
cadeia de caracteres
OBRIGATÓRIO
Carregando...
outAmount
cadeia de caracteres
OBRIGATÓRIO
Carregando...
feeAmount
cadeia de caracteres
OBRIGATÓRIO
Carregando...
feeMint
cadeia de caracteres
OBRIGATÓRIO
Carregando...
percent
número inteiro
OBRIGATÓRIO
Carregando...
bps
número inteiro
Carregando...
instructionVersion
cadeia de caracteres
Carregando...
contextSlot
número inteiro
Carregando...
timeTaken
número inteiro
Carregando...
Devoluções
tokenLedgerInstruction
objeto
Carregando...
programId
cadeia de caracteres
Carregando...
accounts
matriz
Carregando...
chave pública
cadeia de caracteres
Carregando...
isSigner
booleano
Carregando...
isWritable
booleano
Carregando...
dados
cadeia de caracteres
Carregando...
computeBudgetInstructions
matriz
Carregando...
programId
cadeia de caracteres
Carregando...
accounts
matriz
Carregando...
chave pública
cadeia de caracteres
Carregando...
isSigner
booleano
Carregando...
isWritable
booleano
Carregando...
dados
cadeia de caracteres
Carregando...
setupInstructions
matriz
Carregando...
programId
cadeia de caracteres
Carregando...
accounts
matriz
Carregando...
chave pública
cadeia de caracteres
Carregando...
isSigner
booleano
Carregando...
isWritable
booleano
Carregando...
dados
cadeia de caracteres
Carregando...
swapInstruction
objeto
Carregando...
programId
cadeia de caracteres
Carregando...
accounts
matriz
Carregando...
chave pública
cadeia de caracteres
Carregando...
isSigner
booleano
Carregando...
isWritable
booleano
Carregando...
dados
cadeia de caracteres
Carregando...
cleanupInstruction
objeto
Carregando...
programId
cadeia de caracteres
Carregando...
accounts
matriz
Carregando...
chave pública
cadeia de caracteres
Carregando...
isSigner
booleano
Carregando...
isWritable
booleano
Carregando...
dados
cadeia de caracteres
Carregando...
otherInstructions
matriz
Carregando...
addressLookupTableAddresses
matriz
Carregando...
prioritizationFeeLamports
número inteiro
Carregando...
Pedido
1curl --location 'https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions' \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-instructions' \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"3necessita de "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")67https = Net::HTTP.novo(url.host, url.porta)8https.use_ssl = true910pedido = Líquido::HTTP::POST.novo(url)11pedido["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})8283resposta = https.pedido(pedido)84insere a resposta.read_body85
1exigir "uri"2require "json"3necessita de "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions")67https = Net::HTTP.novo(url.host, url.porta)8https.use_ssl = true910pedido = Líquido::HTTP::POST.novo(url)11pedido["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})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 = {76method: "POST",77cabeçalhos: myHeaders,78body: raw,79redirecionar: "seguir"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions", requestOptions)83.então((resposta) => resposta.texto())84.então((resultado) => console.log(resultado))85.captura((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 = {76method: "POST",77cabeçalhos: myHeaders,78body: raw,79redirecionar: "seguir"80};8182fetch("https://docs-demo.solana-mainnet.quiknode.pro/swap-instructions", requestOptions)83.então((resposta) => resposta.texto())84.então((resultado) => console.log(resultado))85.captura((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}1415async function main(): Promise<void> {16const jupiterApi = createJupiterApiClient(CONFIG);17const wallet = Keypair.generate();1819try {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}4748principal();
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();1819try {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}4748principal();
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}
Ainda não tem uma conta?
Crieendpoint seuendpoint Quicknode endpoint segundos e comece a desenvolver
Comece gratuitamente