Skip to main content
Before executing a swap, request a price quote to preview estimated output amounts. The quote reflects Privy and Uniswap protocol fees in the swap rate. See the fees section for a breakdown of how fees are applied.
View the full API reference for the quote endpoint.

Usage

To get a swap quote via REST API, make a POST request to:
https://api.privy.io/v1/wallets/{wallet_id}/swap/quote

Body

caip2
string
required
Chain identifier in CAIP-2 format (e.g., eip155:8453 for Base). See supported chains.
input_token
string
required
Token address to sell, or "native" for the chain’s native token.
output_token
string
required
Token address to buy, or "native" for the chain’s native token. Must be different from input_token.
amount
string
required
Amount in base units (e.g., wei for ETH).
amount_type
'exact_input' | 'exact_output'
Whether amount refers to the input or output token. Defaults to exact_input.
slippage_bps
number
Maximum slippage tolerance in basis points (e.g., 50 for 0.5%). If omitted, auto-slippage is used.

Response

The response includes the following fields:
caip2
string
Chain identifier.
input_token
string
Token address being sold.
output_token
string
Token address being bought.
input_amount
string
Amount of input token in base units.
est_output_amount
string
Estimated amount of output token in base units, after fees.
minimum_output_amount
string
Minimum output amount accounting for slippage, in base units. Your app can use this value to verify the swap terms before executing.
gas_estimate
string
Estimated gas cost in base units of the native token.

Example

curl -X POST https://api.privy.io/v1/wallets/{wallet_id}/swap/quote \
  -u "<your-app-id>:<your-app-secret>" \
  -H "privy-app-id: <your-app-id>" \
  -H "Content-Type: application/json" \
  -d '{
    "caip2": "eip155:8453",
    "input_token": "native",
    "output_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "amount": "1000000000000000000",
    "amount_type": "exact_input"
  }'
Example response
{
  "caip2": "eip155:8453",
  "input_token": "native",
  "output_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
  "input_amount": "1000000000000000000",
  "est_output_amount": "2000000000",
  "minimum_output_amount": "1980000000",
  "gas_estimate": "150000"
}
Swap quotes reflect real-time market conditions and can change quickly. Fetch a fresh quote before executing a swap to ensure your app displays accurate pricing.