Skip to content
SwapWalletDocs
فارسیGet an API key

Swap between tokens

Convert one token into another from code: at the live rate in one request, or lock a price for 60 seconds and execute it.

A swap converts one token into another inside your account, at SwapWallet’s market rate. It settles at once: the new token is in your balance when the response arrives. There are two ways to do it.

Fast swapQuote, then confirm
RequestsOneTwo
PriceThe live rate at executionLocked for 60 seconds
Use it whenYou accept the market rateYou show the price to a person, or check it in code before committing

Choose which side is fixed

Every swap request names sourceToken and destinationToken, and exactly one amount:

  • sourceAmount sells that much of the source token. Spend 100 USDT on TON.
  • destinationAmount buys that much of the destination token. Get exactly 50 TON, paying in USDT.

Sending both, or neither, is rejected. Amounts are decimal strings, so "0.1" stays exactly 0.1.

Fast swap

One request, executed at the best live rate. The response is the completed TRADE transaction.

POST/v1/market/otc/fast-swap
Terminal
curl -X POST https://swapwallet.app/api/v1/market/otc/fast-swap \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sourceToken": "USDT", "destinationToken": "TON", "sourceAmount": "100"}'

Quote, then confirm

First ask for a price. The response holds both amounts and a swapToken that locks them for 60 seconds. You can ask for up to 30 quotes a minute.

POST/v1/market/otc/price
Terminal
curl -X POST https://swapwallet.app/api/v1/market/otc/price \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sourceToken": "USDT", "destinationToken": "TON", "sourceAmount": "100"}'
JSON
{
  "status": "OK",
  "result": {
    "swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0",
    "source": { "number": "100", "unit": "USDT" },
    "destination": { "number": "101.677", "unit": "TON" },
    "marketRate": 0.9835065944117155,
    "expiresIn": "2026-11-20T09:16:02.418Z"
  }
}

If the price works for you, execute it with the swapToken before expiresIn. The response is just { "status": "OK" }: the swap is done and your balances have changed.

POST/v1/market/otc/order
Terminal
curl -X POST https://swapwallet.app/api/v1/market/otc/order \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0"}'

Only one quote is active at a time. Asking for a new quote, or making a fast swap, cancels the previous one, so don’t quote in parallel for the same account.

After the swap

A fast swap answers with the TRADE transaction itself: what you paid, what you received and the rate you got. Either way the trade is in List transactions with types=TRADE, and your balances reflect it at once.