---
title: "Build swap instructions"
method: POST
path: "/swap-instructions"
---

# Build swap instructions

`POST /swap-instructions`

Build swap instructions without transaction wrapper

## Request body

- SwapRequest
  - `userPublicKey` string, required — User's wallet public key
  - `wrapUnwrapSol` boolean — Automatically wrap/unwrap SOL
  - `txVersion` 'legacy' | 'v0' — Transaction version
  - `computeUnitPriceMicroLamports` integer — Priority fee in microlamports
  - `computeUnitLimit` integer — Compute unit limit
  - `priorityFee` string — Priority fee mode or microlamports
  - `maxPriorityFee` integer — Maximum priority fee cap
  - `tipAccount` string — Tip account pubkey
  - `tipLamports` integer — Tip amount in lamports
  - `feeAccount` string — Platform fee recipient
  - `feeBps` integer — Platform fee in basis points
  - `feeFromInput` boolean — Take fee from input
  - `chargeBps` integer — Extra charge on positive slippage
  - `quoteResponse` QuoteResponse, required
    - `inputMint` string, required — Input token mint address
    - `outputMint` string, required — Output token mint address
    - `amountIn` string, required — Input amount in lamports
    - `amountOut` string, required — Expected output amount in lamports
    - `minAmountOut` string, required — Minimum output amount after slippage
    - `feeAmount` string, required — Total fees paid in lamports
    - `priceImpact` number, required — Price impact percentage
    - `slippageBps` integer, required — Slippage used in basis points
    - `routePlan` RouteStep[], required — Array of routing steps
      - `programId` string, required — DEX program ID
      - `dex` string, required — DEX name
      - `pool` string, required — Pool address
      - `inputMint` string, required — Step input mint
      - `outputMint` string, required — Step output mint
      - `amountIn` string, required — Step input amount
      - `amountOut` string, required — Step output amount
      - `feeAmount` string, required — Step fees
      - `priceImpact` number, required — Step price impact
      - `percent` integer — Percentage of total input
    - `swapUsdValue` string — USD value of the input amount
    - `priorityFee` PriorityFeeInfo
      - `recommended` integer, required — Recommended priority fee in microlamports
      - `level` string, required — Priority level used
      - `levels` PriorityFeeLevels
        - `min` integer — Minimum priority fee
        - `low` integer — Low priority fee
        - `medium` integer — Medium priority fee
        - `high` integer — High priority fee
        - `veryHigh` integer — Very high priority fee
        - `unsafeMax` integer — Maximum priority fee
    - `platformFee` PlatformFeeConfig
      - `feeBps` integer, required — Fee in basis points
      - `feeAccount` string, required — Fee recipient address
    - `contextSlot` integer, required — Solana slot when quote was generated
    - `timeTaken` number, required — Time taken to generate quote in seconds

## Response `200`

Successful instruction build

- SwapInstructionsResponse
  - `tokenLedgerInstruction` SerializedInstruction
    - `programId` string, required — Program ID
    - `accounts` InstructionAccount[], required
      - `pubkey` string, required — Account public key
      - `isSigner` boolean, required — Whether account signs
      - `isWritable` boolean, required — Whether account is writable
    - `data` string, required — Base64-encoded instruction data
  - `computeBudgetInstructions` SerializedInstruction[]
    - `programId` string, required — Program ID
    - `accounts` InstructionAccount[], required
      - `pubkey` string, required — Account public key
      - `isSigner` boolean, required — Whether account signs
      - `isWritable` boolean, required — Whether account is writable
    - `data` string, required — Base64-encoded instruction data
  - `setupInstructions` SerializedInstruction[]
    - `programId` string, required — Program ID
    - `accounts` InstructionAccount[], required
      - `pubkey` string, required — Account public key
      - `isSigner` boolean, required — Whether account signs
      - `isWritable` boolean, required — Whether account is writable
    - `data` string, required — Base64-encoded instruction data
  - `swapInstruction` SerializedInstruction
    - `programId` string, required — Program ID
    - `accounts` InstructionAccount[], required
      - `pubkey` string, required — Account public key
      - `isSigner` boolean, required — Whether account signs
      - `isWritable` boolean, required — Whether account is writable
    - `data` string, required — Base64-encoded instruction data
  - `cleanupInstruction` SerializedInstruction
    - `programId` string, required — Program ID
    - `accounts` InstructionAccount[], required
      - `pubkey` string, required — Account public key
      - `isSigner` boolean, required — Whether account signs
      - `isWritable` boolean, required — Whether account is writable
    - `data` string, required — Base64-encoded instruction data
  - `addressLookupTableAddresses` string[]

---

[API](https://skmtc.dev/solanatracker/apis/solana-tracker-data-api.md) · [All operations](https://skmtc.dev/solanatracker/apis/solana-tracker-data-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/solanatracker/solana-tracker-data-api/revisions/c07c6f82d0c4/schema)
