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": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"requiresTokenApproval": true,
"allRoutes": [
{
"tx": {
"to": "<string>",
"data": "<string>",
"value": "<string>",
"chainId": 123
},
"txId": "<string>",
"vmId": "evm",
"amountIn": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"optimism"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "optimism"
}
]
}
],
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"optimism"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "optimism"
}
]
}

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 Type of action to perform.

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

The address of the sender/user EVM address (20 bytes hex)

srcChainId
integer
required

Source chain ID Chain ID. Find in the list of supported networks

srcToken
string
required

Source token address EVM address (20 bytes hex)

dstChainId
integer
required

Destination chain ID Chain ID. Find in the list of supported networks

dstToken
string
required

Destination token address EVM address (20 bytes hex)

slippage
number<float>
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 Swap direction for the action.

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

Address to receive the swapped tokens

swap-action EVM address (20 bytes hex)

to
string

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

evm-calldata-tx EVM address (20 bytes hex)

data
string

Calldata for the transaction

evm-calldata-tx Hex string with 0x prefix

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 EVM address (20 bytes hex)

bridgeIds
enum<string>[]

Specific bridge protocols to use

Optional: Will default to all available protocols

Bridge protocol identifier.

Available options:
optimism,
arbitrum,
oft,
yield-oft,
hyperlane,
ghost,
mayan,
across,
relay,
alt-vm-1,
alt-vm-2
refundTo
string

Alternate address to receive refunds

Optional: Will default to the sender EVM address (20 bytes hex)

returnDepositAddress
boolean
default:false

Return a deposit address for deposit-based flows

Optional: Set to true to receive a deposit address in the response

Response

Successful response with action data

tx
EVM Transaction · 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<float>
required

Exchange rate for the swap.

estimatedTxTime
integer
required

Estimated transaction time in seconds.

estimatedPriceImpact
number<float>
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.

Bridge protocol identifier.

Available options:
optimism,
arbitrum,
oft,
yield-oft,
hyperlane,
ghost,
mayan,
across,
relay,
alt-vm-1,
alt-vm-2
bridgeRoute
object[]

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