curl --request GET \
--url https://swap-v2.solanatracker.io/swapimport requests
url = "https://swap-v2.solanatracker.io/swap"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://swap-v2.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://swap-v2.solanatracker.io/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://swap-v2.solanatracker.io/swap"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://swap-v2.solanatracker.io/swap")
.asString();require 'uri'
require 'net/http'
url = URI("https://swap-v2.solanatracker.io/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"txn": "BASE64_TX",
"rate": {
"amountIn": 1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"baseCurrency": {
"mint": "<string>",
"decimals": 123
},
"quoteCurrency": {
"mint": "<string>",
"decimals": 123
},
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "legacy"
}{
"error": "An internal error occurred",
"details": "Unable to fetch pools for token"
}{
"error": "An internal error occurred",
"details": "Unable to fetch pools for token"
}Crear una transacción de swap en Solana con la Swap API
Crea una transacción de swap de Solana serializada con GET /swap, fírmala y envíala desde tu wallet. Incluye opciones de slippage y priority fee.
curl --request GET \
--url https://swap-v2.solanatracker.io/swapimport requests
url = "https://swap-v2.solanatracker.io/swap"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://swap-v2.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://swap-v2.solanatracker.io/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://swap-v2.solanatracker.io/swap"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://swap-v2.solanatracker.io/swap")
.asString();require 'uri'
require 'net/http'
url = URI("https://swap-v2.solanatracker.io/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"txn": "BASE64_TX",
"rate": {
"amountIn": 1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"baseCurrency": {
"mint": "<string>",
"decimals": 123
},
"quoteCurrency": {
"mint": "<string>",
"decimals": 123
},
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "legacy"
}{
"error": "An internal error occurred",
"details": "Unable to fetch pools for token"
}{
"error": "An internal error occurred",
"details": "Unable to fetch pools for token"
}swap-v2.solanatracker.io. Sigue activa y cobra una comisión de plataforma en cada swap. Raptor es una API de swap independiente en raptor.solanatracker.io, actualmente gratuita y sin API key.Resumen
El endpoint swap construye transacciones de swap de tokens en Solana. Recibes una transacción serializada que firmas y emites con tu wallet.Plataformas soportadas
- Pump.fun - Tokens de la plataforma de lanzamiento
- PumpSwap - Pools de liquidez de Pump.fun
- Orca - Liquidez concentrada
- Meteora - Pools dinámicos
- Moonshot - Nuevos lanzamientos
- Raydium - V4 AMM, CPMM, Launchpad
- Jupiter - Routing agregado
Ejemplos con SDK
import { SolanaTracker } from 'solana-swap';
const tracker = new SolanaTracker('YOUR_API_KEY', 'YOUR_PRIVATE_KEY');
// Basic swap
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112', // SOL
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: 0.1,
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS',
priorityFee: 0.000005,
txVersion: 'v0'
});
console.log('Transaction:', swap.txn);
slippage: 10 significa 10%.from solana_swap import SolanaTracker
tracker = SolanaTracker('YOUR_API_KEY', 'YOUR_PRIVATE_KEY')
# Basic swap
swap = tracker.swap(
from_token='So11111111111111111111111111111111111111112',
to_token='4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
from_amount=0.1,
slippage=10,
payer='YOUR_WALLET_ADDRESS',
priority_fee=0.000005,
tx_version='v0'
)
print('Transaction:', swap['txn'])
curl -X GET "https://swap-v2.solanatracker.io/swap?from=So11111111111111111111111111111111111111112&to=4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R&fromAmount=0.1&slippage=10&payer=YOUR_WALLET_ADDRESS&priorityFee=0.000005&txVersion=v0"
Parámetros clave
Formatos de cantidad
El parámetrofromAmount acepta:
- Numérico:
1,0.5- Cantidad exacta - Auto:
"auto"- Saldo completo del wallet - Porcentaje:
"50%","25%"- Porcentaje del saldo
Priority fees
// Manual fee
{ priorityFee: 0.000005 }
// Automatic with level
{
priorityFee: "auto",
priorityFeeLevel: "high" // min, low, medium, high, veryHigh, unsafeMax
}
Fees de partner / referidos
Añade tus propias fees de partner o referidos para monetización:{
fee: "YOUR_WALLET:0.1", // 0.1% to your wallet
feeType: "add" // or "deduct" (SOL only)
}
Ejemplos
Swap con cantidad automática
// Swap entire balance
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112',
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: "auto",
slippage: 15,
payer: 'YOUR_WALLET_ADDRESS'
});
Swap con porcentaje
// Swap 50% of balance
const swap = await tracker.swap({
from: 'TOKEN_ADDRESS',
to: 'So11111111111111111111111111111111111111112',
fromAmount: "50%",
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS'
});
Swap con fee personalizada
// Add 0.1% fee
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112',
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: 1,
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS',
fee: 'YOUR_FEE_WALLET:0.1',
feeType: 'add'
});
Estructura de respuesta
{
"txn": "BASE64_ENCODED_TRANSACTION",
"rate": {
"amountIn": 0.1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "v0"
}
Fees de la plataforma Solana Tracker
Fee estándar: 0,5% del valor de la transacción- Se deduce de la salida
- Se muestra en
platformFee(lamports) yplatformFeeUI(SOL) - Hay descuentos por volumen
Errores comunes
| Error | Solución |
|---|---|
| Dirección de token inválida | Verifica que las direcciones sean válidas |
| Cantidad inválida | Usa número, “auto” o porcentaje |
| Slippage inválido | Establece entre 0-100 |
| Token sin pools | El token puede estar deslistado |
| Liquidez insuficiente | Prueba con una cantidad menor |
Próximos pasos
Endpoint Rate
SDK de JavaScript
Parámetros de consulta
The base token address
"So11111111111111111111111111111111111111112"
The quote token address
"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
The amount of the base token to swap. Accepts numeric value, 'auto' for full wallet balance, or percentage like '50%'
1
Maximum acceptable slippage percentage or 'auto' for dynamic slippage (Beta)
0 <= x <= 10010
Public key of the wallet sending the transaction
"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y"
Amount in SOL to increase transaction priority or 'auto'
0.000005
Priority level when priorityFee is set to 'auto'
min, low, medium, high, veryHigh, unsafeMax Transaction version
v0, legacy Custom fee for your users in format 'WALLET_ADDRESS:PERCENTAGE'
^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"
Custom tip for Jito or similar services in format 'WALLET_ADDRESS:SOL_AMOUNT'
^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$Fee application type. 'deduct' option is only used when the from address is SOL
add, deduct Disable multi-hop swaps
¿Esta página le ayudó?