Swaps

Create Swap Quote

Changed on

Previews the price of a swap before you create it. A fiat pair quotes the same rate creating the swap fills at; name the account with account_id or user_id to quote the rate for that account. No funds move, nothing is saved, and no authentication is required unless you name an account.

post/swaps/quote

Request

  • Base URL
    https://api.whop.com/api/v1
  • Auth
    • none
    • or HTTP bearer

Headers

Idempotency-Key, string
Example:d9105228-4a08-46b1-8b91-42fed586d383

A unique key that makes this request safe to retry. See Idempotent requests.

Request body

object required
account_id, string

Fiat pairs only: business account to quote the swap for, prefixed biz_. Requires a credential with payout:transfer_funds on that account. Provide this, user_id, or neither for a public quote.

amount, string required

Source token amount.

from_address, string nullable

Source wallet address used for the quote.

from_chain, union

Source chain name or chain ID. Defaults to the source token's chain when omitted.

from_token, string required

Source token contract address or ticker symbol, such as "USDT".

metadata, object

Metadata to include with the quote response.

slippage_bps, integer nullable

Maximum slippage tolerance in basis points.

to_address, string nullable

Destination wallet address used for the quote.

to_chain, union

Destination chain name or chain ID. Defaults to the destination token's chain when omitted.

to_token, string required

Destination token contract address or ticker symbol, such as "XAUT".

user_id, string

Fiat pairs only: the caller's own user ID, prefixed user_, to quote the swap for their personal account. Provide this or account_id.

Example request

{
  "amount": "100",
  "from_address": "0x6f1c0a3d5b2e4f8a9c7d1e0b3a5f7c9d2e4b6a80",
  "from_chain": "plasma",
  "from_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "metadata": {
    "external_id": "shop_4417"
  },
  "slippage_bps": 50,
  "to_address": "0x9d2e4b6a806f1c0a3d5b2e4f8a9c7d1e0b3a5f7c",
  "to_chain": "plasma",
  "to_token": "0x1b64b9025eebb9a6239575df9ea4b9ac46d4d193"
}

Response

swap quote created

object required
amount_in, string required

Source token amount used for the quote.

amount_out, string required

Estimated destination token amount.

amount_out_min, string

Minimum destination amount after slippage.

bridge_fee, string nullable

Estimated bridge fee for cross-chain swaps.

estimated_duration_seconds, integer nullable

Estimated time for the swap to complete.

fee_bps, integer required

Whop fee in basis points.

from_address, string nullable

Source wallet address used for the quote.

from_token, object required

Resolved source token details.

metadata, object required

Metadata from the request.

mid_market_rate, string nullable required

Mid-market exchange rate for a fiat pair, before the FX charge, as a decimal string. rate is after the FX charge. null for a crypto pair.

object, 'swap_quote' required
rate, string required

Quoted exchange rate.

requires_token_approval, boolean nullable

Whether the source token needs approval before swapping.

to_address, string nullable

Destination wallet address used for the quote.

to_token, object required

Resolved destination token details.

Example response

{
  "amount_in": "100",
  "amount_out": "0.15",
  "amount_out_min": "0.148",
  "bridge_fee": "0.25",
  "estimated_duration_seconds": 30,
  "fee_bps": 100,
  "from_address": "0x6f1c0a3d5b2e4f8a9c7d1e0b3a5f7c9d2e4b6a80",
  "from_token": {
    "address": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "chain_id": 9745,
    "decimals": 6,
    "network": "plasma",
    "symbol": "USDT"
  },
  "metadata": {
    "external_id": "shop_4417"
  },
  "object": "swap_quote",
  "rate": "1.5",
  "requires_token_approval": true,
  "to_address": "0x9d2e4b6a806f1c0a3d5b2e4f8a9c7d1e0b3a5f7c",
  "to_token": {
    "address": "0x1b64b9025eebb9a6239575df9ea4b9ac46d4d193",
    "chain_id": 9745,
    "decimals": 6,
    "network": "plasma",
    "symbol": "XAUT"
  }
}

Changes

    • info

      added the required property mid_market_rate to the response with the status

    • info

      the endpoint scheme security bearerAuth was added to the API

    • info

      added the new optional request property account_id

    1 more change in this revision