Build swap transaction
curl --request POST \
--url https://raptor-beta.solanatracker.io/swap \
--header 'Content-Type: application/json' \
--data '
{
"userPublicKey": "<string>",
"quoteResponse": {
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"minAmountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"slippageBps": 123,
"routePlan": [
{
"programId": "<string>",
"dex": "<string>",
"pool": "<string>",
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"percent": 123
}
],
"contextSlot": 123,
"timeTaken": 123,
"swapUsdValue": "<string>"
},
"wrapUnwrapSol": true,
"txVersion": "v0",
"computeUnitPriceMicroLamports": 123,
"computeUnitLimit": 123,
"priorityFee": "<string>",
"maxPriorityFee": 123,
"tipAccount": "<string>",
"tipLamports": 123,
"feeAccount": "<string>",
"feeBps": 123,
"feeFromInput": false,
"chargeBps": 123
}
'import requests
url = "https://raptor-beta.solanatracker.io/swap"
payload = {
"userPublicKey": "<string>",
"quoteResponse": {
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"minAmountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"slippageBps": 123,
"routePlan": [
{
"programId": "<string>",
"dex": "<string>",
"pool": "<string>",
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"percent": 123
}
],
"contextSlot": 123,
"timeTaken": 123,
"swapUsdValue": "<string>"
},
"wrapUnwrapSol": True,
"txVersion": "v0",
"computeUnitPriceMicroLamports": 123,
"computeUnitLimit": 123,
"priorityFee": "<string>",
"maxPriorityFee": 123,
"tipAccount": "<string>",
"tipLamports": 123,
"feeAccount": "<string>",
"feeBps": 123,
"feeFromInput": False,
"chargeBps": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
userPublicKey: '<string>',
quoteResponse: {
inputMint: '<string>',
outputMint: '<string>',
amountIn: '<string>',
amountOut: '<string>',
minAmountOut: '<string>',
feeAmount: '<string>',
priceImpact: 123,
slippageBps: 123,
routePlan: [
{
programId: '<string>',
dex: '<string>',
pool: '<string>',
inputMint: '<string>',
outputMint: '<string>',
amountIn: '<string>',
amountOut: '<string>',
feeAmount: '<string>',
priceImpact: 123,
percent: 123
}
],
contextSlot: 123,
timeTaken: 123,
swapUsdValue: '<string>'
},
wrapUnwrapSol: true,
txVersion: 'v0',
computeUnitPriceMicroLamports: 123,
computeUnitLimit: 123,
priorityFee: '<string>',
maxPriorityFee: 123,
tipAccount: '<string>',
tipLamports: 123,
feeAccount: '<string>',
feeBps: 123,
feeFromInput: false,
chargeBps: 123
})
};
fetch('https://raptor-beta.solanatracker.io/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://raptor-beta.solanatracker.io/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userPublicKey' => '<string>',
'quoteResponse' => [
'inputMint' => '<string>',
'outputMint' => '<string>',
'amountIn' => '<string>',
'amountOut' => '<string>',
'minAmountOut' => '<string>',
'feeAmount' => '<string>',
'priceImpact' => 123,
'slippageBps' => 123,
'routePlan' => [
[
'programId' => '<string>',
'dex' => '<string>',
'pool' => '<string>',
'inputMint' => '<string>',
'outputMint' => '<string>',
'amountIn' => '<string>',
'amountOut' => '<string>',
'feeAmount' => '<string>',
'priceImpact' => 123,
'percent' => 123
]
],
'contextSlot' => 123,
'timeTaken' => 123,
'swapUsdValue' => '<string>'
],
'wrapUnwrapSol' => true,
'txVersion' => 'v0',
'computeUnitPriceMicroLamports' => 123,
'computeUnitLimit' => 123,
'priorityFee' => '<string>',
'maxPriorityFee' => 123,
'tipAccount' => '<string>',
'tipLamports' => 123,
'feeAccount' => '<string>',
'feeBps' => 123,
'feeFromInput' => false,
'chargeBps' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://raptor-beta.solanatracker.io/swap"
payload := strings.NewReader("{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://raptor-beta.solanatracker.io/swap")
.header("Content-Type", "application/json")
.body("{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://raptor-beta.solanatracker.io/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}"
response = http.request(request)
puts response.read_body{
"swapTransaction": "<string>",
"lastValidBlockHeight": 123,
"contextSlot": 123,
"prioritizationFeeLamports": 123
}{
"error": "<string>",
"code": 123
}API Reference
Build swap transaction
根据询价结果组装完整可签名的交换交易。
POST
/
swap
Build swap transaction
curl --request POST \
--url https://raptor-beta.solanatracker.io/swap \
--header 'Content-Type: application/json' \
--data '
{
"userPublicKey": "<string>",
"quoteResponse": {
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"minAmountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"slippageBps": 123,
"routePlan": [
{
"programId": "<string>",
"dex": "<string>",
"pool": "<string>",
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"percent": 123
}
],
"contextSlot": 123,
"timeTaken": 123,
"swapUsdValue": "<string>"
},
"wrapUnwrapSol": true,
"txVersion": "v0",
"computeUnitPriceMicroLamports": 123,
"computeUnitLimit": 123,
"priorityFee": "<string>",
"maxPriorityFee": 123,
"tipAccount": "<string>",
"tipLamports": 123,
"feeAccount": "<string>",
"feeBps": 123,
"feeFromInput": false,
"chargeBps": 123
}
'import requests
url = "https://raptor-beta.solanatracker.io/swap"
payload = {
"userPublicKey": "<string>",
"quoteResponse": {
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"minAmountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"slippageBps": 123,
"routePlan": [
{
"programId": "<string>",
"dex": "<string>",
"pool": "<string>",
"inputMint": "<string>",
"outputMint": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"feeAmount": "<string>",
"priceImpact": 123,
"percent": 123
}
],
"contextSlot": 123,
"timeTaken": 123,
"swapUsdValue": "<string>"
},
"wrapUnwrapSol": True,
"txVersion": "v0",
"computeUnitPriceMicroLamports": 123,
"computeUnitLimit": 123,
"priorityFee": "<string>",
"maxPriorityFee": 123,
"tipAccount": "<string>",
"tipLamports": 123,
"feeAccount": "<string>",
"feeBps": 123,
"feeFromInput": False,
"chargeBps": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
userPublicKey: '<string>',
quoteResponse: {
inputMint: '<string>',
outputMint: '<string>',
amountIn: '<string>',
amountOut: '<string>',
minAmountOut: '<string>',
feeAmount: '<string>',
priceImpact: 123,
slippageBps: 123,
routePlan: [
{
programId: '<string>',
dex: '<string>',
pool: '<string>',
inputMint: '<string>',
outputMint: '<string>',
amountIn: '<string>',
amountOut: '<string>',
feeAmount: '<string>',
priceImpact: 123,
percent: 123
}
],
contextSlot: 123,
timeTaken: 123,
swapUsdValue: '<string>'
},
wrapUnwrapSol: true,
txVersion: 'v0',
computeUnitPriceMicroLamports: 123,
computeUnitLimit: 123,
priorityFee: '<string>',
maxPriorityFee: 123,
tipAccount: '<string>',
tipLamports: 123,
feeAccount: '<string>',
feeBps: 123,
feeFromInput: false,
chargeBps: 123
})
};
fetch('https://raptor-beta.solanatracker.io/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://raptor-beta.solanatracker.io/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'userPublicKey' => '<string>',
'quoteResponse' => [
'inputMint' => '<string>',
'outputMint' => '<string>',
'amountIn' => '<string>',
'amountOut' => '<string>',
'minAmountOut' => '<string>',
'feeAmount' => '<string>',
'priceImpact' => 123,
'slippageBps' => 123,
'routePlan' => [
[
'programId' => '<string>',
'dex' => '<string>',
'pool' => '<string>',
'inputMint' => '<string>',
'outputMint' => '<string>',
'amountIn' => '<string>',
'amountOut' => '<string>',
'feeAmount' => '<string>',
'priceImpact' => 123,
'percent' => 123
]
],
'contextSlot' => 123,
'timeTaken' => 123,
'swapUsdValue' => '<string>'
],
'wrapUnwrapSol' => true,
'txVersion' => 'v0',
'computeUnitPriceMicroLamports' => 123,
'computeUnitLimit' => 123,
'priorityFee' => '<string>',
'maxPriorityFee' => 123,
'tipAccount' => '<string>',
'tipLamports' => 123,
'feeAccount' => '<string>',
'feeBps' => 123,
'feeFromInput' => false,
'chargeBps' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://raptor-beta.solanatracker.io/swap"
payload := strings.NewReader("{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://raptor-beta.solanatracker.io/swap")
.header("Content-Type", "application/json")
.body("{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://raptor-beta.solanatracker.io/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"userPublicKey\": \"<string>\",\n \"quoteResponse\": {\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"minAmountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"slippageBps\": 123,\n \"routePlan\": [\n {\n \"programId\": \"<string>\",\n \"dex\": \"<string>\",\n \"pool\": \"<string>\",\n \"inputMint\": \"<string>\",\n \"outputMint\": \"<string>\",\n \"amountIn\": \"<string>\",\n \"amountOut\": \"<string>\",\n \"feeAmount\": \"<string>\",\n \"priceImpact\": 123,\n \"percent\": 123\n }\n ],\n \"contextSlot\": 123,\n \"timeTaken\": 123,\n \"swapUsdValue\": \"<string>\"\n },\n \"wrapUnwrapSol\": true,\n \"txVersion\": \"v0\",\n \"computeUnitPriceMicroLamports\": 123,\n \"computeUnitLimit\": 123,\n \"priorityFee\": \"<string>\",\n \"maxPriorityFee\": 123,\n \"tipAccount\": \"<string>\",\n \"tipLamports\": 123,\n \"feeAccount\": \"<string>\",\n \"feeBps\": 123,\n \"feeFromInput\": false,\n \"chargeBps\": 123\n}"
response = http.request(request)
puts response.read_body{
"swapTransaction": "<string>",
"lastValidBlockHeight": 123,
"contextSlot": 123,
"prioritizationFeeLamports": 123
}{
"error": "<string>",
"code": 123
}请求体
application/json
User's wallet public key
Show child attributes
Show child attributes
Automatically wrap/unwrap SOL
Transaction version
可用选项:
legacy, v0 Priority fee in microlamports
Compute unit limit
Priority fee mode or microlamports
Maximum priority fee cap
Tip account pubkey
Tip amount in lamports
Platform fee recipient
Platform fee in basis points
Take fee from input
Extra charge on positive slippage
此页面对您有帮助吗?
⌘I