跳转到主要内容
GET
Get Swap Quote
本页介绍的是较早的 Solana Tracker Swap API(swap-v2.solanatracker.io)。它仍在运行,每笔兑换收取平台费。Raptor 是另一款独立的兑换 API(raptor.solanatracker.io),目前免费,无需 API 密钥。

概览

rate 端点为代币兑换提供执行交易前的价格报价。用它在用户即将兑换时向其显示预期输出量和价格影响。
此端点仅用于兑换前报价。不要将其用作免费的定价或市场数据 API。出于非兑换目的的过多请求可能导致速率限制。

用例

  • 兑换前报价:在执行兑换前获取准确定价
  • 滑点计算:向用户显示最低保证输出
  • 价格影响检查:验证交易规模是否可接受

SDK 示例

响应字段

示例响应

理解价格影响

价格影响显示您的交易使市场价格变动多少:
  • < 1% - 流动性极好,可放心交易
  • 1-5% - 大多数交易可接受
  • > 5% - 考虑较小的交易、不同的路径或等待更多流动性

在兑换前验证

常见错误

下一步

Swap 端点

执行兑换交易

JavaScript SDK

安装 SDK

查询参数

from
string
必填

The base token address

示例:

"So11111111111111111111111111111111111111112"

to
string
必填

The quote token address

示例:

"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"

amount
number
必填

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

示例:

1

slippage
number
必填

The maximum acceptable slippage percentage

必填范围: 0 <= x <= 100
示例:

10

响应

Successful rate quote

amountIn
number

The amount of the source token used for the conversion

示例:

1

amountOut
number

The amount of the destination token that would be received

示例:

9181.330823048

minAmountOut
number

The minimum amount of the destination token after applying slippage

示例:

9089.517514818

currentPrice
number

The current market price for the token pair

示例:

9181.330823048

executionPrice
number

The actual price at which the trade would be executed

示例:

9089.517514818

priceImpact
number

The difference between market price and execution price as a fraction

示例:

0.0334641736518774

fee
number

The trading fee charged for the transaction

示例:

0.01

baseCurrency
object
quoteCurrency
object
platformFee
integer

The fee charged by the platform in lamports

示例:

9000000

platformFeeUI
number

The platform fee in SOL

示例:

0.009