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

# Build Solana Swap Instructions with Raptor

> Get individual swap instructions from a Raptor quote so you can add your own and build the transaction yourself. POST /swap-instructions.

Same input as `/swap`, but returns the individual instructions so you can add your own and build the transaction yourself.

The swap is built as an ordinary swap unless you send `jitRouting: true`, so it can be called from your own program. If the response includes `quoteResponse`, use its amounts. When `topLevelOnly` is `true`, put `swapInstruction` last in the transaction and do not call it through CPI.


## OpenAPI

````yaml /raptor/http/openapi.json post /swap-instructions
openapi: 3.0.3
info:
  title: Raptor Swap API
  description: >-
    Solana swap quotes, ready-to-sign swap transactions, transaction sending and
    status tracking. No API key is required.
  version: 1.0.0
  contact:
    name: Solana Tracker Discord
    url: https://discord.gg/JH2e9rR9fc
servers:
  - url: https://raptor.solanatracker.io
    description: Hosted Raptor
security: []
paths:
  /swap-instructions:
    post:
      summary: Build swap instructions
      description: >-
        Same input as `/swap`, but returns the individual instructions so you
        can add your own and build the transaction yourself.


        The swap is built as an ordinary swap unless you send `jitRouting:
        true`, so it can be called from your own program. If the response
        includes `quoteResponse`, use its amounts. When `topLevelOnly` is
        `true`, put `swapInstruction` last in the transaction and do not call it
        through CPI.
      operationId: buildSwapInstructions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRequest'
            example:
              userPublicKey: YOUR_WALLET_ADDRESS
              quoteResponse:
                inputMint: So11111111111111111111111111111111111111112
                outputMint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                amountIn: '100000000'
                amountOut: '11703794'
                minAmountOut: '11645275'
                priceImpact: 0
                slippageBps: 50
                routePlan:
                  - programId: 9H6tua7jkLhdm3w8BvgpTn5LZNU7g4ZynDmCiNN3q6Rp
                    dex: Humidifi
                    pool: 8sKQHfjNhvmAw94PhfvfMcytmqW6jmxvwieYyzXCCPu
                    inputMint: So11111111111111111111111111111111111111112
                    outputMint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                    amountIn: '100000000'
                    amountOut: '11703794'
                    priceImpact: 0
                    percent: 100
                contextSlot: 454215309
                timeTaken: 0.026
                quoteId: AbvXxjPyBhaxiDuRNB5XM54c_V8e-S0jPyMceNLpJQmU
      responses:
        '200':
          description: Instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapInstructionsResponse'
              example:
                computeBudgetInstructions:
                  - programId: ComputeBudget111111111111111111111111111111
                    accounts: []
                    data: AsBcFQA=
                setupInstructions:
                  - programId: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
                    accounts:
                      - pubkey: YOUR_WALLET_ADDRESS
                        isSigner: true
                        isWritable: true
                    data: AQ==
                tokenLedgerInstruction: null
                swapInstruction:
                  programId: RaptorD5ojtsqDDtJeRsunPLg6GvLYNnwKJWxYE4m87
                  accounts:
                    - pubkey: YOUR_WALLET_ADDRESS
                      isSigner: true
                      isWritable: true
                  data: …
                cleanupInstruction: null
                addressLookupTableAddresses:
                  - …
        '400':
          $ref: '#/components/responses/BadRequest'
        '422':
          $ref: '#/components/responses/InvalidBody'
        '500':
          $ref: '#/components/responses/BuildFailed'
components:
  schemas:
    SwapRequest:
      type: object
      required:
        - userPublicKey
        - quoteResponse
      properties:
        userPublicKey:
          type: string
          description: Wallet that signs and pays for the swap
        quoteResponse:
          $ref: '#/components/schemas/QuoteResponse'
        wrapUnwrapSol:
          type: boolean
          default: true
          description: Wrap and unwrap native SOL automatically
        txVersion:
          type: string
          enum:
            - V0
            - LEGACY
            - V1
          default: V0
          description: >-
            Transaction format. Case-sensitive. `LEGACY` and `V1` do not support
            JIT routes; quote with `jitRouting=false` to use them.
        priorityFee:
          type: string
          description: >-
            A level (`min`, `low`, `medium`, `auto`, `high`, `veryHigh`,
            `turbo`, `unsafeMax`) or a total fee in lamports as a string, such
            as `"50000"`. Default `auto`.
          example: high
        maxPriorityFee:
          type: integer
          description: Cap on the compute unit price, in micro-lamports
        computeUnitPriceMicroLamports:
          type: integer
          description: Exact compute unit price in micro-lamports. Overrides `priorityFee`.
        computeUnitLimit:
          type: integer
          description: Compute unit limit
        tipAccount:
          type: string
          description: Account that receives a SOL tip, such as a Jito tip account
        tipLamports:
          type: integer
          description: Tip amount in lamports
        feeAccount:
          type: string
          description: Wallet that receives your platform fee
        feeBps:
          type: integer
          description: Platform fee in basis points
        feeFromInput:
          type: boolean
          default: false
          description: Take the platform fee from the input token
        chargeBps:
          type: integer
          description: Fee on positive slippage, in basis points
        jitRouting:
          type: string
          enum:
            - auto
            - 'true'
            - 'false'
          default: auto
          description: >-
            On `/swap`, `auto` keeps the quote's route. On `/swap-instructions`,
            you get a JIT swap only when this is `true`.
    SwapInstructionsResponse:
      type: object
      description: >-
        Put the instructions in this order: `computeBudgetInstructions`,
        `setupInstructions`, `tokenLedgerInstruction`, `swapInstruction`,
        `cleanupInstruction`, `tipInstruction`. Skip any that are null.
        Exception: if `topLevelOnly` is `true`, `swapInstruction` must be last.
      properties:
        computeBudgetInstructions:
          type: array
          items:
            $ref: '#/components/schemas/Instruction'
        setupInstructions:
          type: array
          description: Creates missing token accounts and wraps SOL
          items:
            $ref: '#/components/schemas/Instruction'
        tokenLedgerInstruction:
          allOf:
            - $ref: '#/components/schemas/Instruction'
          nullable: true
        swapInstruction:
          $ref: '#/components/schemas/Instruction'
        cleanupInstruction:
          allOf:
            - $ref: '#/components/schemas/Instruction'
          nullable: true
          description: Unwraps SOL
        tipInstruction:
          $ref: '#/components/schemas/Instruction'
        addressLookupTableAddresses:
          type: array
          description: Address lookup tables to load when compiling a V0 transaction
          items:
            type: string
        topLevelOnly:
          type: boolean
          description: >-
            `true` for a JIT swap: `swapInstruction` must be the last
            instruction and must not be called through CPI
        quoteResponse:
          allOf:
            - $ref: '#/components/schemas/QuoteResponse'
          description: The quote these instructions were built for. Use its amounts.
        transactionConfig:
          type: object
          additionalProperties: true
          description: Compute budget settings, returned when `txVersion` is `V1`
    QuoteResponse:
      type: object
      description: >-
        Quote returned by `GET /quote`. Send it back unchanged as
        `quoteResponse`.
      required:
        - inputMint
        - outputMint
        - amountIn
        - amountOut
        - minAmountOut
        - priceImpact
        - slippageBps
        - routePlan
        - contextSlot
        - timeTaken
      properties:
        inputMint:
          type: string
          description: Mint of the token sold
        outputMint:
          type: string
          description: Mint of the token bought
        amountIn:
          type: string
          description: Amount sold, in the input token's smallest unit
        amountOut:
          type: string
          description: Expected amount received, in the output token's smallest unit
        minAmountOut:
          type: string
          description: >-
            Least amount the swap will accept after slippage. The transaction
            fails rather than fill below this.
        feeAmount:
          type: string
          description: Pool fees for the route, when reported
        priceImpact:
          type: number
          description: Price impact in percent (`0.25` = 0.25%)
        slippageBps:
          type: integer
          description: Slippage used, in basis points
        routePlan:
          type: array
          description: Steps of the route, in order
          items:
            $ref: '#/components/schemas/RouteStep'
        swapUsdValue:
          type: string
          description: USD value of the input amount
        platformFee:
          $ref: '#/components/schemas/PlatformFee'
        tokenTransfers:
          $ref: '#/components/schemas/TokenTransfers'
        contextSlot:
          type: integer
          description: Slot the quote was computed at
        timeTaken:
          type: number
          description: Time to compute the quote, in seconds
        jitRouting:
          type: boolean
          description: '`true` when the quote uses a just-in-time route'
        quoteId:
          type: string
          description: Reference to the stored execution plan. Expires after a few seconds.
        searchMode:
          type: string
          enum:
            - fast
            - deep
          description: Search mode used
    Instruction:
      type: object
      required:
        - programId
        - accounts
        - data
      properties:
        programId:
          type: string
        accounts:
          type: array
          items:
            type: object
            required:
              - pubkey
              - isSigner
              - isWritable
            properties:
              pubkey:
                type: string
              isSigner:
                type: boolean
              isWritable:
                type: boolean
        data:
          type: string
          description: Instruction data, base64
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: What went wrong
        code:
          type: integer
          description: HTTP status code
    RouteStep:
      type: object
      required:
        - programId
        - dex
        - pool
        - inputMint
        - outputMint
        - amountIn
        - amountOut
        - priceImpact
      properties:
        programId:
          type: string
          description: DEX program ID
        dex:
          type: string
          description: DEX name
        pool:
          type: string
          description: Pool address
        inputMint:
          type: string
          description: Mint going into this step
        outputMint:
          type: string
          description: Mint coming out of this step
        amountIn:
          type: string
          description: Amount into this step
        amountOut:
          type: string
          description: Amount out of this step
        feeAmount:
          type: string
          description: Pool fee for this step, when reported
        priceImpact:
          type: number
          description: Price impact of this step, in percent
        percent:
          type: integer
          description: Share of the input sent through this step
    PlatformFee:
      type: object
      description: Your platform fee settings, as applied to the quote
      properties:
        feeAccount:
          type: string
          description: Wallet that receives the fee
        feeBps:
          type: integer
          description: Fee in basis points
        feeFromInput:
          type: boolean
          description: '`true` if the fee is taken from the input token'
        chargeBps:
          type: integer
          description: Fee on positive slippage, in basis points
    TokenTransfers:
      type: object
      description: >-
        Present only when the input or output token charges a Token-2022
        transfer fee. Amounts are strings in the token's smallest unit.
      properties:
        depositFee:
          type: string
          description: Transfer fee charged on the input token
        deliveryFee:
          type: string
          description: Transfer fee charged on the output token
        netOutput:
          type: string
          description: What reaches the wallet after platform and transfer fees
  responses:
    BadRequest:
      description: A parameter is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: 'Invalid amount: must be greater than 0'
            code: 400
        text/plain:
          schema:
            type: string
          example: 'Failed to deserialize query string: missing field `amount`'
    InvalidBody:
      description: >-
        No route was found (JSON), or the JSON body has a missing, unknown-value
        or wrongly typed field, or the quote was changed or expired (plain
        text).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: 'Failed to get quote: No multi-hop route found'
            code: 422
        text/plain:
          schema:
            type: string
          examples:
            staleQuote:
              summary: Quote expired or modified
              value: >-
                Failed to deserialize the JSON body into the target type:
                quoteResponse: Quote expired, modified or unavailable on this
                API instance; request a fresh quote
            badTxVersion:
              summary: Wrong txVersion casing
              value: >-
                Failed to deserialize the JSON body into the target type:
                txVersion: unknown variant `v0`, expected one of `V1`, `V0`,
                `LEGACY`
    BuildFailed:
      description: >-
        The transaction could not be built. If the error mentions an expired
        plan, get a new quote and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: 'Failed to build swap: Execution plan expired'
            code: 500

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.