Swap API Documentation

API now supports:

  • Moonshot
  • Pump.fun tokens
  • Raydium
  • Raydium CPMM
  • Orca
  • Meteora
  • Any token supported by Jupiter

Endpoints

GET /swap

curl --location 'https://swap-v2.solanatracker.io/swap?from=So11111111111111111111111111111111111111112&to=4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R&fromAmount=1&slippage=10&payer=PAYER_ADDRESS'

POST /swap

curl --location 'https://swap-v2.solanatracker.io/swap' \
--header 'Content-Type: application/json' \
--data '{
    "from": "So11111111111111111111111111111111111111112",
    "to": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
    "amount": 1,
    "slippage": 15,
    "payer": "arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y",
    "priorityFee": 0.0005,
    "feeType": "add",
    "fee": "arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"
}'

Request Parameters

Both GET and POST requests support the following parameters:

ParameterDescriptionExample
fromThe base token addressSo11111111111111111111111111111111111111112 (SOL)
toThe quote token address4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R (RAY)
amountThe amount of the base token to swap. Can be a specific value, “auto” to use full wallet amount, or a percentage (e.g., “50%”) to use that portion of the wallet balance1, "auto", or "50%"
slippageMaximum acceptable slippage percentage10
payerPublic key of the wallet sending the transactionPAYER_ADDRESS

Optional Parameters

ParameterDescriptionExample
priorityFeeAmount in SOL to increase transaction processing priority0.000005 or set it to auto and provide an priority level
priorityFeeLevelRequired if priorityFee is set to automin, low, medium, high, veryHigh, unsafeMax, for more info read this blog post
txVersionTransaction version ("v0" or "legacy")"v0"
feeCharge a custom fee to your users for each transaction (earn sol for each swap)WALLET_ADDRESS:PERCENTAGE
feeTypeFee application type (default: "add")"add" or "deduct"

Note: The feeType parameter is set to "add" by default. The "deduct" option is only used when the from address is SOL.

Example Response

{
   "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":"So11111111111111111111111111111111111111112",
         "decimals":9
      },
      "quoteCurrency":{
         "mint":"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
         "decimals":6
      },
      "platformFee":9000000,
      "platformFeeUI":0.009
   },
   "timeTaken":0.016,
   "type":"legacy"
}

Loading the Transaction

const serializedTransactionBuffer = Buffer.from(res.txn, "base64");
let txn;
 
if (res.type === 'v0') {
  txn = VersionedTransaction.deserialize(serializedTransactionBuffer);
} else {
  txn = Transaction.from(serializedTransactionBuffer);
}
 
if (!txn) return false;

Sending the Transaction

Using React Wallet Adapter

if (res.type === 'v0' && txn) {
  await wallet.signTransaction(txn);
}
 
const txid = await wallet.sendTransaction(txn, connection, {
  skipPreflight: true,
  maxRetries: 4,
});

Using NodeJS

const keypair = Keypair.fromSecretKey(bs58.decode('YOUR_SECRET_KEY'));
 
let txid;
 
if (res.type === 'v0' ) {
  const txn = VersionedTransaction.deserialize(serializedTransactionBuffer);
  txn.sign([keypair]);
 
  txid = await connection.sendRawTransaction(txn.serialize(), {
    skipPreflight: true,
  });
} else {
  const txn = Transaction.from(serializedTransactionBuffer);
  txn.sign(keypair);
  const rawTransaction = txn.serialize();
  txid = await connection.sendRawTransaction(rawTransaction, {
    skipPreflight: true,
  });
}

Fees

We charge a 0.5% fee on each successful transaction. For high-volume usage on public bots or sites, contact us via Discord or email ([email protected]) to discuss reduced fees.