Skip to main content
GET
/
rate
Get Swap Quote
curl --request GET \
  --url https://swap-v2.solanatracker.io/rate
{
  "amountIn": 1,
  "amountOut": 9181.330823048,
  "minAmountOut": 9089.517514818,
  "currentPrice": 9181.330823048,
  "executionPrice": 9089.517514818,
  "priceImpact": 0.0334641736518774,
  "fee": 0.01,
  "baseCurrency": {
    "decimals": 9,
    "mint": "So11111111111111111111111111111111111111112"
  },
  "quoteCurrency": {
    "decimals": 9,
    "mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
  },
  "platformFee": 9000000,
  "platformFeeUI": 0.009
}

Overview

The rate endpoint provides price quotes for token swaps before executing a transaction. Use this to show users the expected output amount and price impact when they’re ready to swap.
This endpoint is for pre-swap quotes only. Do not use it as a free pricing or market data API. Excessive requests for non-swap purposes may result in rate limiting.

Use Cases

  • Pre-Swap Quotes: Get accurate pricing before executing a swap
  • Slippage Calculation: Show users the minimum guaranteed output
  • Price Impact Check: Validate that trade size is acceptable

SDK Examples

import { SolanaTracker } from 'solana-swap';

const tracker = new SolanaTracker('YOUR_API_KEY');

// Get rate quote before swap
const quote = await tracker.getRate({
  from: 'So11111111111111111111111111111111111111112', // SOL
  to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
  amount: 1,
  slippage: 10
});

console.log(`Expected: ${quote.amountOut} tokens`);
console.log(`Minimum: ${quote.minAmountOut} tokens`);
console.log(`Price impact: ${(quote.priceImpact * 100).toFixed(2)}%`);

Response Fields

FieldTypeDescription
amountInnumberInput token amount
amountOutnumberExpected output token amount
minAmountOutnumberMinimum output after slippage
currentPricenumberCurrent market price
executionPricenumberActual execution price
priceImpactnumberPrice impact as decimal (0.05 = 5%)
feenumberTrading fee
platformFeenumberPlatform fee in lamports
platformFeeUInumberPlatform fee in SOL

Example Response

{
  "amountIn": 1,
  "amountOut": 9181.330823048,
  "minAmountOut": 9089.517514818,
  "currentPrice": 9181.330823048,
  "executionPrice": 9089.517514818,
  "priceImpact": 0.0334641736518774,
  "fee": 0.01,
  "baseCurrency": {
    "decimals": 9,
    "mint": "So11111111111111111111111111111111111111112"
  },
  "quoteCurrency": {
    "decimals": 9,
    "mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
  },
  "platformFee": 9000000,
  "platformFeeUI": 0.009
}

Understanding Price Impact

Price impact shows how much your trade moves the market price:
  • < 1% - Excellent liquidity, proceed with confidence
  • 1-5% - Acceptable for most trades
  • > 5% - Consider splitting into smaller trades or increasing slippage

Validate Before Swap

// Check rate before executing swap
async function validateAndSwap(swapParams) {
  // Get quote first
  const quote = await tracker.getRate({
    from: swapParams.from,
    to: swapParams.to,
    amount: swapParams.amount,
    slippage: swapParams.slippage
  });
  
  // Check price impact
  if (quote.priceImpact > 0.05) {
    throw new Error('Price impact too high');
  }
  
  // Execute swap
  return await tracker.swap(swapParams);
}

Common Errors

ErrorDescriptionSolution
Invalid or missing token addressToken address is invalidVerify token addresses
Invalid amountAmount is not validEnsure amount is positive
Invalid slippage toleranceSlippage not between 0-100Set slippage 0-100
Unable to fetch poolsCannot find liquidityToken may lack active pools

Next Steps

Swap Endpoint

Execute the swap transaction

JavaScript SDK

Install the SDK

Query Parameters

from
string
required

The base token address

Example:

"So11111111111111111111111111111111111111112"

to
string
required

The quote token address

Example:

"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"

amount
number
required

The amount of the base token to convert (in native units, not lamports)

Example:

1

slippage
number
required

The maximum acceptable slippage percentage

Required range: 0 <= x <= 100
Example:

10

Response

Successful rate quote

amountIn
number

The amount of the source token used for the conversion

Example:

1

amountOut
number

The amount of the destination token that would be received

Example:

9181.330823048

minAmountOut
number

The minimum amount of the destination token after applying slippage

Example:

9089.517514818

currentPrice
number

The current market price for the token pair

Example:

9181.330823048

executionPrice
number

The actual price at which the trade would be executed

Example:

9089.517514818

priceImpact
number

The difference between market price and execution price as a fraction

Example:

0.0334641736518774

fee
number

The trading fee charged for the transaction

Example:

0.01

baseCurrency
object
quoteCurrency
object
platformFee
integer

The fee charged by the platform in lamports

Example:

9000000

platformFeeUI
number

The platform fee in SOL

Example:

0.009