跳到正文
QSwap文档

API 参考

QSwap API 的每个接口。它是应用与 Jupiter 之间的小型代理。与 docs/API-CONTRACT.md 保持一致。

基础 URL

请求发往哪里
浏览器$NEXT_PUBLIC_API_URL/swap/orderhttps://api.jup.agSOLANA_RPC_URL
  • 没有版本前缀:是 /swap/order,不是 /v1/swap/order
  • Jupiter key 和 RPC URL 留在服务器上
源码: docs/API-CONTRACT.md

约定

读懂一个请求体
GET /swap/order?
  inputMint=So111…11121
  &outputMint=EPjF…Dt1v
  &amount=10000000002
  &slippageBps=503

← 404
{ "error": { code: "NO_ROUTE", message, details } }4
  1. 1mint 是 base58。SOL 是 wrapped SOL 的 mint。
  2. 2数量:最小单位,字符串形式
  3. 3bps:50 = 0.5%。不传即为自动。
  4. 4每个错误都是这个结构

接口

接口 · v1
  • GET/health

    Liveness and version.

    参数
    无参数
    响应
    200
    示例
    {
      "ok": true,
      "version": "0.1.0"
    }
    curl "$QSWAP_API/health"
  • GET/config

    Cluster, public RPC URL, fees, slippage limits, feature flags, default pair. Cache 5 minutes.

    参数
    无参数
    响应
    200Config
    示例
    {
      "cluster": "mainnet-beta",
      "rpcUrl": "https://<api>/rpc",
      "explorerTxUrl": "https://solscan.io/tx/{signature}",
      "fees": {
        "referralBps": 0
      },
      "slippage": {
        "defaultBps": null,
        "maxBps": 5000
      },
      "features": {
        "quantumSwap": false
      },
      "defaultPair": {
        "inputMint": "So11111111111111111111111111111111111111112",
        "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
      }
    }
    curl "$QSWAP_API/config"
  • GET/tokens

    Jupiter's verified token list, trimmed. Cached 10 minutes on the server.

    参数
    • listqueryverified必填
    响应
    200{ tokens: Token[] }400Error429Error502Error
    示例
    {
      "tokens": [
        {
          "mint": "So11111111111111111111111111111111111111112",
          "symbol": "SOL",
          "name": "Wrapped SOL",
          "decimals": 9,
          "icon": "https://…",
          "verified": true,
          "tags": [
            "verified"
          ],
          "usdPrice": 141.2,
          "organicScore": 98.1,
          "audit": {
            "isSus": false,
            "mintAuthorityDisabled": true,
            "freezeAuthorityDisabled": true
          }
        }
      ]
    }
    curl "$QSWAP_API/tokens?list=verified"
  • GET/tokens/search

    Search by symbol, name, or up to 100 comma-separated mints. Cached 60 s per query.

    参数
    • queryquerystring必填Text or mint list
    响应
    200{ tokens: Token[] }400Error429Error502Error
    示例
    {
      "tokens": [
        {
          "mint": "So11111111111111111111111111111111111111112",
          "symbol": "SOL",
          "name": "Wrapped SOL",
          "decimals": 9,
          "icon": "https://…",
          "verified": true,
          "tags": [
            "verified"
          ],
          "usdPrice": 141.2,
          "organicScore": 98.1,
          "audit": {
            "isSus": false,
            "mintAuthorityDisabled": true,
            "freezeAuthorityDisabled": true
          }
        }
      ]
    }
    curl "$QSWAP_API/tokens/search?query=USDC"
  • GET/prices

    USD prices from Jupiter Price v3. Mints with no price are omitted. Cached 10 s.

    参数
    • mintsquerystring必填Comma list, up to 50
    响应
    200400Error429Error502Error
    示例
    {
      "prices": {
        "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": {
          "usdPrice": 1,
          "priceChange24h": 0.01
        }
      }
    }
    curl "$QSWAP_API/prices?mints=So11111111111111111111111111111111111111112,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
  • GET/balances/:owner

    SOL and SPL / Token-2022 balances from Solana RPC. Zero balances are dropped.

    参数
    • ownerpathbase58 address必填
    响应
    200400Error429Error502Error
    示例
    {
      "owner": "…",
      "solLamports": "123",
      "tokens": [
        {
          "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
          "amount": "1000000",
          "decimals": 6
        }
      ]
    }
    curl "$QSWAP_API/balances/<owner>"
  • GET/swap/order

    Proxies Jupiter GET /swap/v2/order (ExactIn). Without taker it is a quote and transaction is null. Adds the referral fee when one is configured.

    参数
    • inputMintquerybase58 mint必填
    • outputMintquerybase58 mint必填
    • amountquerystring必填Smallest units of inputMint
    • takerquerybase58 addressOmit for a quote
    • slippageBpsqueryintegerOmit for auto (RTSE)
    响应
    200Order400Error404Error429Error502Error
    示例
    {
      "requestId": "…",
      "inputMint": "So11111111111111111111111111111111111111112",
      "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "inAmount": "10000000000",
      "outAmount": "1412380000",
      "otherAmountThreshold": "1405318100",
      "slippageBps": 50,
      "priceImpact": -0.04,
      "inUsdValue": 1412.6,
      "outUsdValue": 1412.38,
      "feeBps": 10,
      "feeMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "router": "metis",
      "gasless": false,
      "routePlan": [
        {
          "label": "Raydium CLMM",
          "ammKey": "…",
          "inputMint": "So11111111111111111111111111111111111111112",
          "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
          "inAmount": "5500000000",
          "outAmount": "…",
          "percent": 55
        }
      ],
      "transaction": null,
      "lastValidBlockHeight": null,
      "expireAt": null
    }
    curl "$QSWAP_API/swap/order?inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=1000000000"
  • POST/swap/execute

    Proxies Jupiter POST /swap/v2/execute. A Failed status is still HTTP 200, with code and error filled in.

    参数
    无参数
    请求体 · { signedTransaction, requestId }
    {
      "signedTransaction": "<base64>",
      "requestId": "…"
    }
    响应
    200ExecuteResult400Error502Error
    示例
    {
      "status": "Success",
      "signature": "…",
      "slot": "…",
      "code": 0,
      "error": null,
      "inputAmountResult": "10000000000",
      "outputAmountResult": "1411902000"
    }
    curl -X POST "$QSWAP_API/swap/execute" \
      -H 'content-type: application/json' \
      -d '{"signedTransaction":"<base64>","requestId":"<requestId>"}'
  • POST/rpc

    JSON-RPC passthrough to the server's Solana RPC, for an allowlist of read and simulate methods. Others: -32601.

    参数
    无参数
    请求体 · JSON-RPC 2.0
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLatestBlockhash",
      "params": []
    }
    响应
    200
    curl -X POST "$QSWAP_API/rpc" \
      -H 'content-type: application/json' \
      -d '{"jsonrpc":"2.0","id":1,"method":"getSlot"}'
源码: docs/API-CONTRACT.md

速率限制与缓存

Jupiter 速率限制(按组织计)
套餐每秒请求数
Keyless0.5
Free1
Developer10
Launch50

POST /swap/v2/execute 有自己单独的、更大的额度。

API 缓存了什么,让一个用户不等于一次 Jupiter 调用
已验证列表10 min
代币搜索,按查询60 s
价格10 s
配置,在浏览器中5 min
源码: developers.jup.ag · docs/API-CONTRACT.md

当触及 Jupiter 的限制时,API 返回 429 RATE_LIMITED 并带上 Retry-After 头。Jupiter 自己的头是 x-ratelimit-remaining 和 x-ratelimit-reset。