Swap Endpoints

Execute a token swap

Changed on

Get executable transactions for token-to-token swaps. Supports same-chain and cross-chain swaps with multiple from/to assets.

post/api/v2/swap/execute

Request

Request body

addressstring required

Wallet address executing the swap

recipientstring nullable

Recipient address (defaults to sender address)

slippage_tolerancenumber double nullable

Slippage tolerance as a decimal (0.0 to 0.5, default: 0.01)

Example request

{
  "address": "0x1234567890abcdef1234567890abcdef12345678",
  "from_assets": [
    {
      "amount": "1000000000000000000",
      "chain": "ethereum",
      "contract": "0x0000000000000000000000000000000000000000"
    }
  ],
  "slippage_tolerance": 0.01,
  "to_assets": [
    {
      "amount": "1000000000000000000",
      "chain": "ethereum",
      "contract": "0x0000000000000000000000000000000000000000"
    }
  ]
}

Response

Swap execution data retrieved successfully

Example response

{
  "quote": {
    "costs": [
      {
        "type": "GAS",
        "usd": "0.5"
      }
    ],
    "estimated_duration_ms": 30000,
    "marketplace_fee_bps": 50,
    "price_impact": {
      "percent": "-0.08",
      "usd": "-1.5"
    },
    "recommended_slippage": 2,
    "refresh_after_ms": 2000,
    "route_errors": [
      {
        "type": "INSUFFICIENT_FUNDS"
      }
    ],
    "slippage_tolerance": 0.01,
    "swap_provider": "RELAY",
    "total_cost_usd": 1869,
    "total_price_usd": 1850.5
  },
  "transactions": [
    {
      "chain": "ethereum",
      "svm": {
        "instructions": [
          {
            "accounts": [
              {
                "pubkey": "So11111111111111111111111111111111111111112"
              }
            ],
            "data": "01020304",
            "program_id": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
          }
        ],
        "transaction_config": {
          "compute_unit_limit": 200000,
          "priority_fee_lamports": "5000"
        }
      }
    }
  ]
}

Changes

    • breaking

      the response property / became nullable for the status

    • breaking

      the response property / became nullable for the status

    • breaking

      the response property // became nullable for the status

    • breaking

      the response property // became nullable for the status

    • breaking

      the response property // became nullable for the status

    • breaking

      the / response's property type changed from object to no type for status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • warning

      added the new EXECUTION enum value to the /// response property for the response status

    • info

      the request property became nullable

    • info

      the request property became nullable

    • info

      added the media type */* for the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      added subschema #2 to the / response property anyOf list for the response status