curl --request GET \
--url https://api-v2.swaps.xyz/api/getAction \
--header 'x-api-key: <api-key>'import requests
url = "https://api-v2.swaps.xyz/api/getAction"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-v2.swaps.xyz/api/getAction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.swaps.xyz/api/getAction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.swaps.xyz/api/getAction"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.swaps.xyz/api/getAction")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.swaps.xyz/api/getAction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"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>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"requiresTokenApproval": true,
"requiresRegisterTransaction": 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>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"requiresRegisterTransaction": true,
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"<string>"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "<string>"
}
],
"executionsType": "DEFAULT",
"executions": [
{
"txType": "evmTransactionSign",
"data": "<string>",
"signature": "<string>"
}
],
"relayerFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
}
}
],
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"<string>"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "<string>"
}
],
"executionsType": "DEFAULT",
"executions": [
{
"txType": "evmTransactionSign",
"data": "<string>",
"signature": "<string>"
}
],
"relayerFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
}
}Get Action
Generates a transaction for cross-chain swaps, bridges, and calls. The action includes transaction data, routing information, and fee calculations for executing the requested operation.
curl --request GET \
--url https://api-v2.swaps.xyz/api/getAction \
--header 'x-api-key: <api-key>'import requests
url = "https://api-v2.swaps.xyz/api/getAction"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-v2.swaps.xyz/api/getAction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.swaps.xyz/api/getAction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.swaps.xyz/api/getAction"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.swaps.xyz/api/getAction")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.swaps.xyz/api/getAction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"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>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"requiresTokenApproval": true,
"requiresRegisterTransaction": 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>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountInMax": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOut": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"amountOutMin": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"protocolFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"applicationFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"exchangeRate": 123,
"estimatedTxTime": 123,
"estimatedPriceImpact": 123,
"requiresRegisterTransaction": true,
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"<string>"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "<string>"
}
],
"executionsType": "DEFAULT",
"executions": [
{
"txType": "evmTransactionSign",
"data": "<string>",
"signature": "<string>"
}
],
"relayerFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
}
}
],
"bridgeFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
},
"bridgeIds": [
"<string>"
],
"bridgeRoute": [
{
"srcChainId": 123,
"dstChainId": 123,
"srcBridgeToken": "<string>",
"dstBridgeToken": "<string>",
"bridgeId": "<string>"
}
],
"executionsType": "DEFAULT",
"executions": [
{
"txType": "evmTransactionSign",
"data": "<string>",
"signature": "<string>"
}
],
"relayerFee": {
"chainId": 123,
"address": "<string>",
"name": "<string>",
"symbol": "<string>",
"decimals": 123,
"isNative": true,
"amount": "<string>",
"logo": "<string>",
"swapsXyzCode": "<string>",
"usdAmount": 123
}
}Authorizations
Limited demo key for API Reference: 5c951bc81da566bbd030ba8e20724063.
Query Parameters
Type of action to perform Type of action to perform.
swap-action, evm-calldata-tx, polymarket The address of the sender/user Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Source chain ID Chain ID. Find in the list of supported networks.
Source token address Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Destination chain ID Chain ID. Find in the list of supported networks.
Destination token address Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Slippage tolerance in bps
0 <= x <= 10000The exact in or exact out amount of the swap
Required: for swap-action
Required: for polymarket action type
^[0-9]+$Swap direction for the action
Required: for swap-action
For polymarket, optional — defaults to exact-amount-in (recommended).
Swap direction for the action.
exact-amount-in, exact-amount-out Address to receive the swapped tokens
Optional: for swap-action
Required: for polymarket action type (should be the proxy wallet address)
Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
The EVM address of the target contract (20 bytes hex)
Required: for evm-calldata-tx action type
Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Calldata for the transaction
Required: for evm-calldata-tx action type
Hex string with 0x prefix
^0x[a-fA-F0-9]*$Value to send with transaction
Optional: for evm-calldata-tx action type
^[0-9]+$The amount of Erc20 being transferred
Optional: for evm-calldata-tx action type (use for calls requiring Erc20 transfers)
^[0-9]+$The Erc20 spender requiring approval for the transaction call
Optional: for evm-calldata-tx action type (will default to the to address)
Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Solana address that pays for tx fees and rent (e.g. ATA creation). Only used for Solana same chain swaps. Transaction must be signed by both the user and the sponsor.
Optional: When provided, the sponsor covers transaction costs on behalf of the user. Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Specific bridge protocols to use
Optional: Will default to all available protocols
Bridge protocol identifier (e.g. "across", "relay", "mayan").
Alternate address to receive refunds
Optional: Will default to the sender
Address type - can be EvmAddress, HyperCoreAddress, SolanaAddress, or AltVmAddress.
Return a deposit address for deposit-based flows
Optional: Set to true to receive a deposit address in the response
Application fees configuration as JSON array
Optional: Will default to fees configured for the application
Example: [{ "bps": 50, "receiverAddress": "0x..." }]
Polymarket user ID - returned from POST /workflows/polymarket/createOrFetchPolymarketUser
Required: for polymarket action type
Order side for Polymarket orders
Required: for polymarket action type
BUY, SELL Polymarket CLOB token ID
Required: for polymarket action type
Polymarket order type
Required: for polymarket action type
FOK: Fill or Kill (market order)FAK: Fill and Kill (market order)
FOK, FAK Price tick size for Polymarket orders
Required: for polymarket action type
0.01, 0.001, 0.0001 Negative risk flag for Polymarket
Required: for polymarket action type
true, false Request gasless execution. When true, the response includes an executions array of signed steps to relay through the gasless provider instead of broadcasting a transaction directly.
Optional: Only supported on chains with a configured gasless provider (currently Tron). Requires the API key to have gasless enabled.
Response
Successful response with action data
Transaction data for execution
- EVM Transaction
- Solana Transaction
- Alt VM Transaction
- HyperCore Transaction
- HyperCore Transaction
- Tron Transaction
- Ton Transaction
Show child attributes
Show child attributes
Transaction ID
^0x[a-fA-F0-9]*$Virtual machine identifier.
evm, solana, alt-vm, hypercore, tron, ton Expected amount to input (exclusive of slippage - recommended value to display in frontend)
Show child attributes
Show child attributes
Maximum amount to input (inclusive of slippage)
Show child attributes
Show child attributes
Expected amount delivered to users (exclusive of slippage - recommended value to display in frontend)
Show child attributes
Show child attributes
Minimum amount delivered to users (inclusive of slippage)
Show child attributes
Show child attributes
Swaps.xyz fee
Show child attributes
Show child attributes
Application fee (your fee!)
Show child attributes
Show child attributes
Exchange rate for the swap.
Estimated transaction time in seconds.
Estimated price impact percentage.
Flag indicating whether the transaction object requires a source token approval check.
Flag indicating whether the transaction requires registration via the registerTxs endpoint. Mandatory for non-EVM transactions.
All available routes for the action.
Show child attributes
Show child attributes
Bridge fee (from aggregated providers)
Show child attributes
Show child attributes
Bridge IDs used in the route.
Bridge protocol identifier (e.g. "across", "relay", "mayan").
Bridge route information (src chain + token, dst chain + token, BridgeId)
Show child attributes
Show child attributes
Indicates the execution mode. GASLESS when gasless=true was requested and a relay provider is available; DEFAULT otherwise.
DEFAULT, GASLESS Ordered list of signing steps the client must complete before calling POST /submitTx. Only present when executionsType is GASLESS.
A single signing step returned in the executions array of a gasless getAction response. Only available for Tron same-chain swaps. The client must sign each item in order and include the signatures when calling POST /submitTx.
- Option 1
- Option 2
Show child attributes
Show child attributes
Fee charged by the relay provider, denominated in USDT. If non-zero, the user must hold USDT in addition to the source token. Only present when executionsType is GASLESS.
Show child attributes
Show child attributes