> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 計算交換報價（固定輸出）

> 計算達到所需輸出金額所需的輸入金額。
適用於你知道目標輸出的交換。




## OpenAPI

````yaml /zh-Hant/api-reference/openapi/route-api-v2.yaml get /compute/swap-base-out
openapi: 3.0.3
info:
  title: Raydium 交易 API（Route V2）
  version: 1.0.0
  description: |
    Solana 伺服器端交換交易建構工具。此 API 生成序列化的交換交易，無需客戶端運行 RPC 連接或完整的 Raydium SDK。

    回應遵循標準信封格式：
    - **成功**：`{ id: string, success: true, data: {...} }`
    - **錯誤**：`{ id: string, success: false, msg: string }`
  contact:
    name: Raydium
    url: https://raydium.io
servers:
  - url: https://transaction-v1.raydium.io
    description: Mainnet
  - url: https://transaction-v1-devnet.raydium.io
    description: Devnet
security: []
tags:
  - name: Compute
    description: 用於交換報價計算的唯讀端點（無交易建構）。
  - name: Transaction
    description: 構建已序列化的交換交易，準備簽署和廣播。
paths:
  /compute/swap-base-out:
    get:
      tags:
        - Compute
      summary: 計算交換報價（固定輸出）
      description: |
        計算達到所需輸出金額所需的輸入金額。
        適用於你知道目標輸出的交換。
      operationId: computeSwapBaseOut
      parameters:
        - name: inputMint
          in: query
          required: true
          schema:
            type: string
          description: 輸入代幣的 Mint 地址。
          example: EPjFWdd5Au5WrWSNY8jk5oHE3TkM3TvhEhBNj9xtJzwQ
        - name: outputMint
          in: query
          required: true
          schema:
            type: string
          description: 輸出代幣的 Mint 地址。
          example: So11111111111111111111111111111111111111112
        - name: amount
          in: query
          required: true
          schema:
            type: string
          description: 所需的輸出金額（以最小單位計）。
          example: '5000000'
        - name: slippageBps
          in: query
          required: true
          schema:
            type: string
          description: 最大滑點容差，以基點計（0–10000）。
          example: '50'
        - name: txVersion
          in: query
          required: true
          schema:
            type: string
            enum:
              - V0
              - LEGACY
          description: Solana 交易版本。
          example: V0
      responses:
        '200':
          description: 交換報價計算成功。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeSwapResponse'
        '400':
          description: 無效的輸入參數。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ComputeSwapResponse:
      type: object
      properties:
        id:
          type: string
          description: 唯一的請求識別碼（UUID）。
          example: 550e8400-e29b-41d4-a716-446655440000
        success:
          type: boolean
          description: 計算是否成功。
          example: true
        version:
          type: string
          description: API 回應版本。
          example: V1
        data:
          type: object
          description: 交換計算結果。
          properties:
            inputAmount:
              type: string
              description: 輸入金額（以最小單位計）。
            outputAmount:
              type: string
              description: 預期輸出金額（考慮滑點）。
            priceImpact:
              type: string
              description: 價格影響百分比（例如「0.5」表示 0.5%）。
            routes:
              type: array
              description: 使用的交換路線和流動性池的陣列。
              items:
                type: object
    ErrorResponse:
      type: object
      properties:
        id:
          type: string
          description: 唯一請求識別碼。
        success:
          type: boolean
          example: false
        version:
          type: string
          example: V1
        msg:
          type: string
          description: 錯誤訊息代碼（例如 REQ_SLIPPAGE_BPS_ERROR、REQ_WALLET_ERROR）。

````