Create Swap Quote
Changed onPreviews 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.
Request
- Base URLhttps://api.whop.com/api/v1
- Auth
- none
- or HTTP bearer
Headers
A unique key that makes this request safe to retry. See Idempotent requests.
Request body
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.
Source token amount.
Source wallet address used for the quote.
Source chain name or chain ID. Defaults to the source token's chain when omitted.
Source token contract address or ticker symbol, such as "USDT".
Metadata to include with the quote response.
Maximum slippage tolerance in basis points.
Destination wallet address used for the quote.
Destination chain name or chain ID. Defaults to the destination token's chain when omitted.
Destination token contract address or ticker symbol, such as "XAUT".
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
Source token amount used for the quote.
Estimated destination token amount.
Minimum destination amount after slippage.
Estimated bridge fee for cross-chain swaps.
Estimated time for the swap to complete.
Whop fee in basis points.
Source wallet address used for the quote.
Resolved source token details.
Metadata from the request.
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.
Quoted exchange rate.
Whether the source token needs approval before swapping.
Destination wallet address used for the quote.
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_rateto the response with the status
- info
- info
the endpoint scheme security
bearerAuthwas added to the API - info
added the new optional request property
account_id
1 more change in this revision
- info