Skip to main content
POST
Python (SDK)

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

Request model for swap endpoint.

Inherits swap params and adds context fields (owner, chain, gas_sponsorship).

token_in
string
default:USDC
required

Token to sell (input). Provide a token symbol from a limited set (e.g., 'USDC') or any token address.

Examples:

"USDC"

"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"

token_out
string
default:USDT
required

Token to buy (output). Provide a token symbol from a limited set (e.g., 'USDT') or any token address.

Examples:

"USDT"

"0xdAC17F958D2ee523a2206206994597C13D831ec7"

amount_in
default:0.01
required

Human-readable amount of token_in to swap (token units, not wei).

Required range: x > 0
Example:

1.5

owner
string
default:0x06A9aF046187895AcFc7258450B15397CAc67400
required

The owner's wallet address.

Example:

"0x06A9aF046187895AcFc7258450B15397CAc67400"

chain
enum<string>
default:base
required

Target blockchain network where the swap will execute.

Available options:
base,
ethereum,
arbitrum,
hyperevm,
tempo,
bsc
Example:

"base"

action_type
string
default:V2_SWAP

Action type identifier for swap operations.

Allowed value: "V2_SWAP"
slippage
default:0.5

Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).

Example:

0.5

gas_sponsorship
boolean
default:false

Optionally request gas sponsorship. If true, EIP-712 typed data will be returned that must be signed by the owner and submitted to the 'Prepare gas-sponsored transaction' endpoint (/gas_sponsorship/prepare).

Example:

false

Response

Successful Response

estimated_amount_out
string
required

Estimated amount of output token received from the swap.

Pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
transaction
UnsignedTransaction · object | null

Unsigned transaction for direct execution. Present when gas_sponsorship=false.

Example:
eip_712
BatchedSafeOperationsResponse · object | null

EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.

Example: