Skip to main content
GET
/
getAction
Get Action
curl --request GET \
  --url https://api-v2.swaps.xyz/api/getAction \
  --header 'x-api-key: <api-key>'
{
  "tx": {
    "to": "<string>",
    "data": "<string>",
    "value": "<string>",
    "chainId": 123
  },
  "txId": "<string>",
  "vmId": "evm",
  "amountIn": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "amountInMax": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "amountOut": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "amountOutMin": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "protocolFee": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "applicationFee": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "bridgeFee": {
    "address": "<string>",
    "decimals": 123,
    "symbol": "<string>",
    "name": "<string>",
    "chainId": 123,
    "isNative": true,
    "amount": "<string>"
  },
  "bridgeIds": [
    "optimism"
  ],
  "bridgeRoute": [
    {
      "srcChainId": 123,
      "dstChainId": 123,
      "srcBridgeToken": "<string>",
      "dstBridgeToken": "<string>",
      "bridgeId": "optimism"
    }
  ],
  "exchangeRate": 123,
  "estimatedTxTime": 123,
  "estimatedPriceImpact": 123,
  "requiresTokenApproval": true,
  "allRoutes": [
    {
      "tx": {
        "to": "<string>",
        "data": "<string>",
        "value": "<string>",
        "chainId": 123
      },
      "txId": "<string>",
      "vmId": "evm",
      "amountIn": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "amountInMax": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "amountOut": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "amountOutMin": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "protocolFee": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "applicationFee": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "bridgeFee": {
        "address": "<string>",
        "decimals": 123,
        "symbol": "<string>",
        "name": "<string>",
        "chainId": 123,
        "isNative": true,
        "amount": "<string>"
      },
      "bridgeIds": [
        "optimism"
      ],
      "bridgeRoute": [
        {
          "srcChainId": 123,
          "dstChainId": 123,
          "srcBridgeToken": "<string>",
          "dstBridgeToken": "<string>",
          "bridgeId": "optimism"
        }
      ],
      "exchangeRate": 123,
      "estimatedTxTime": 123,
      "estimatedPriceImpact": 123
    }
  ]
}

Authorizations

x-api-key
string
header
required

Limited demo key for API Reference: 5c951bc81da566bbd030ba8e20724063.

Query Parameters

actionType
enum<string>
required

Type of action to perform

Available options:
swap-action,
evm-calldata-tx
sender
string
required

The address of the sender/user

srcChainId
number
required

Source chain ID

srcToken
string
required

Source token address

dstChainId
number
required

Destination chain ID

dstToken
string
required

Destination token address

slippage
number
required

Slippage tolerance in bps

Required range: 0 <= x <= 10000
amount
string

The exact in or exact out amount of the swap

swap-action

swapDirection
enum<string>

Swap direction for the action

swap-action

Available options:
exact-amount-in,
exact-amount-out
recipient
string

Address to receive the swapped tokens

swap-action

to
string

The EVM address of the target contract (20 bytes hex)

evm-calldata-tx

data
string

Calldata for the transaction

evm-calldata-tx

value
string

Value to send with transaction

evm-calldata-tx

erc20Amount
string

The amount of Erc20 being transferred

Optional: Use for calls requiring Erc20 transfers

evm-calldata-tx

erc20Spender
string

The Erc20 spender requiring approval for the transaction call

Optional: Will default to the to address

evm-calldata-tx

bridgeIds
enum<string>[]

Specific bridge protocols to use

Optional: Will default to all available protocols

refundTo
string

Alternate address to receive refunds

Optional: Will default to the sender

Response

200 - application/json

Successful response with action data

tx
object
required

Transaction data for execution

  • EVM Transaction
  • Solana Transaction
  • Alt VM Transaction
  • HyperCore Transaction
txId
string
required

Transaction ID

vmId
enum<string>
required

Virtual machine identifier.

Available options:
evm,
solana,
alt-vm,
hypercore
amountIn
object
required

Expected amount to input (exclusive of slippage - recommended value to display in frontend)

amountInMax
object
required

Maximum amount to input (inclusive of slippage)

amountOut
object
required

Expected amount delivered to users (exclusive of slippage - recommended value to display in frontend)

amountOutMin
object
required

Minimum amount delivered to users (inclusive of slippage)

protocolFee
object
required

Swaps.xyz fee

applicationFee
object
required

Application fee (your fee!)

exchangeRate
number
required

Exchange rate for the swap.

estimatedTxTime
integer
required

Estimated transaction time in seconds.

estimatedPriceImpact
number
required

Estimated price impact percentage.

requiresTokenApproval
boolean
required

Flag indicating whether the transaction object requires a source token approval check.

allRoutes
object[]
required

All available routes for the action.

bridgeFee
object

Bridge fee (from aggregated providers)

bridgeIds
enum<string>[]

Bridge IDs used in the route.

bridgeRoute
object[]

Bridge route information (src chain + token, dst chain + token, BridgeId)

I