A swap converts one token in your balance into another, including to and from the Toman (IRT). It settles at once: both balances change the moment the swap succeeds.
There are two ways to swap:
| Way | When to use it |
|---|---|
| Create a swap | You want it done now at the best current price. One request. |
| Get a swap quote, then execute it | You want to see the exact amounts first. The quote locks the price for 60 seconds. |
In every swap request, set exactly one of the two amounts:
sourceAmount: sell exactly this much of sourceToken.destinationAmount: receive exactly this much of destinationToken.The fee is part of the price, so the trade’s exchangeFee is always 0 and marketRate is the rate you actually got.
You can hold only one quote at a time. Getting a new quote, or creating a swap, cancels your previous quote.
A locked price for a swap. Execute it with its swapToken within 60 seconds.
swapTokenstring (UUID)RequiredPass it to Execute a quoted swap.
sourceMoneyRequiredWhat you’ll give.
numberdecimal stringRequiredThe amount as a decimal string. Trailing zeros are dropped, so 0.5, not 0.50.
unitstringRequiredThe token symbol, such as USDT, TON or BTC. IRT is the Toman; USD marks a value in US dollars.
destinationMoneyRequiredWhat you’ll receive.
numberdecimal stringRequiredThe amount as a decimal string. Trailing zeros are dropped, so 0.5, not 0.50.
unitstringRequiredThe token symbol, such as USDT, TON or BTC. IRT is the Toman; USD marks a value in US dollars.
marketRatenumberRequiredPrice of the market’s base token in its quote token, fee included. For USDT → TON, the price of one TON in USDT.
expiresInISO 8601 timestampRequiredWhen the quote stops being executable: 60 seconds after it was made.
{
"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"
}/v1/market/otc/fast-swapSwaps one token for another right away, at the best price available at that moment, with no separate confirmation. Use it when you don’t need to review the amounts first.
The price isn’t known until the swap is done, so read the actual amounts from the returned transaction.
sourceTokenstringRequiredToken you give, such as USDT, or IRT for the Toman.
destinationTokenstringRequiredToken you receive.
sourceAmountdecimal stringnullableSell exactly this much of sourceToken. Send this or destinationAmount, not both.
destinationAmountdecimal stringnullableReceive exactly this much of destinationToken. Send this or sourceAmount, not both.
Returns the Transaction object of the swap, with type TRADE and status SUCCEED.
INVALID_SWAP_AMOUNTBoth amounts were sent, or neither.
VALIDATION_FAILEDAn amount isn’t a positive number.
INSUFFICIENT_USER_BALANCEYour sourceToken balance doesn’t cover the swap.
MINIMUM_TRADE_DIDNT_MEETThe amount is below the smallest tradable amount.
MARKET_NOT_FOUNDThere is no market between these two tokens.
MARKET_IS_NOT_ACTIVETrading on this market is paused right now.
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"
}'const response = await fetch('https://swapwallet.app/api/v1/market/otc/fast-swap', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SWAPWALLET_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
sourceToken: 'USDT',
destinationToken: 'TON',
sourceAmount: '100',
}),
});
const data = await response.json();
console.log(data.result);import os
import requests
response = requests.post(
"https://swapwallet.app/api/v1/market/otc/fast-swap",
headers={"Authorization": f"Bearer {os.environ['SWAPWALLET_API_KEY']}"},
json={
"sourceToken": "USDT",
"destinationToken": "TON",
"sourceAmount": "100",
},
)
print(response.json()["result"])<?php
$ch = curl_init('https://swapwallet.app/api/v1/market/otc/fast-swap');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWAPWALLET_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'sourceToken' => 'USDT',
'destinationToken' => 'TON',
'sourceAmount' => '100',
]),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data['result']);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"sourceToken": "USDT",
"destinationToken": "TON",
"sourceAmount": "100"
}`)
req, _ := http.NewRequest("POST", "https://swapwallet.app/api/v1/market/otc/fast-swap", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SWAPWALLET_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}{
"status": "OK",
"result": {
"id": 3051877,
"supportCode": "SW-PGE4VWR-YJAX",
"timestamp": 1795166131000,
"type": "TRADE",
"status": "SUCCEED",
"network": "INTERNAL",
"exchangeFee": {
"number": "0",
"unit": "TON"
},
"trade": {
"market": "TON/USDT",
"side": "BUY",
"type": "OTC",
"sourceAmount": {
"number": "100",
"unit": "USDT"
},
"sourceValue": {
"number": "100",
"unit": "USD"
},
"sourceUserCurrencyValue": {
"number": "27240000",
"unit": "IRT"
},
"destinationAmount": {
"number": "101.677",
"unit": "TON"
},
"destinationValue": {
"number": "99.64346",
"unit": "USD"
},
"destinationUserCurrencyValue": {
"number": "27142878",
"unit": "IRT"
},
"marketRate": "0.98350659441171553055263235539994"
}
}
}/v1/market/otc/pricePrices a swap and locks that price for 60 seconds. Show the amounts to your user or check them in code, then pass swapToken to Execute a quoted swap.
A new quote cancels the previous one. With createSwapToken set to false you get the amounts only: the returned swapToken can’t be executed, but the previous quote is still canceled.
sourceTokenstringRequiredToken you give.
destinationTokenstringRequiredToken you receive.
sourceAmountdecimal stringnullableSell exactly this much. Send this or destinationAmount, not both.
destinationAmountdecimal stringnullableReceive exactly this much. Send this or sourceAmount, not both.
createSwapTokenbooleanSet to false to see the amounts without locking a price you can execute.
Returns a Quote object in result.
INVALID_SWAP_AMOUNTBoth amounts were sent, or neither.
VALIDATION_FAILEDAn amount isn’t a positive number.
MARKET_NOT_FOUNDThere is no market between these two tokens.
MARKET_IS_NOT_ACTIVETrading on this market is paused right now.
TOO_MANY_REQUESTSMore than 30 quotes in a minute.
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"
}'const response = await fetch('https://swapwallet.app/api/v1/market/otc/price', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SWAPWALLET_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
sourceToken: 'USDT',
destinationToken: 'TON',
sourceAmount: '100',
}),
});
const data = await response.json();
console.log(data.result);import os
import requests
response = requests.post(
"https://swapwallet.app/api/v1/market/otc/price",
headers={"Authorization": f"Bearer {os.environ['SWAPWALLET_API_KEY']}"},
json={
"sourceToken": "USDT",
"destinationToken": "TON",
"sourceAmount": "100",
},
)
print(response.json()["result"])<?php
$ch = curl_init('https://swapwallet.app/api/v1/market/otc/price');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWAPWALLET_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'sourceToken' => 'USDT',
'destinationToken' => 'TON',
'sourceAmount' => '100',
]),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data['result']);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"sourceToken": "USDT",
"destinationToken": "TON",
"sourceAmount": "100"
}`)
req, _ := http.NewRequest("POST", "https://swapwallet.app/api/v1/market/otc/price", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SWAPWALLET_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}{
"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"
}
}/v1/market/otc/orderExecutes the swap from a quote, at exactly the quoted amounts. Call it within 60 seconds of getting the quote; after that, get a new one.
The response only confirms success. To read the resulting trade, list your transactions with types=TRADE.
swapTokenstring (UUID)RequiredswapToken from the quote.
Returns {"status": "OK"} once the swap is done.
SWAP_ORDER_EXPIREDMore than 60 seconds have passed since the quote.
MARKET_ORDER_REQUEST_NOT_FOUNDThe token is unknown, already used, or canceled by a newer quote or swap.
INSUFFICIENT_USER_BALANCEYour balance no longer covers the swap.
MINIMUM_TRADE_DIDNT_MEETThe amount is below the smallest tradable amount.
MARKET_IS_NOT_ACTIVETrading on this market was paused after the quote.
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"
}'const response = await fetch('https://swapwallet.app/api/v1/market/otc/order', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SWAPWALLET_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
swapToken: '1bb2d955-5d39-450a-b9a2-d900387e09f0',
}),
});
const data = await response.json();
console.log(data.result);import os
import requests
response = requests.post(
"https://swapwallet.app/api/v1/market/otc/order",
headers={"Authorization": f"Bearer {os.environ['SWAPWALLET_API_KEY']}"},
json={
"swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0",
},
)
print(response.json()["result"])<?php
$ch = curl_init('https://swapwallet.app/api/v1/market/otc/order');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWAPWALLET_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'swapToken' => '1bb2d955-5d39-450a-b9a2-d900387e09f0',
]),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data['result']);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0"
}`)
req, _ := http.NewRequest("POST", "https://swapwallet.app/api/v1/market/otc/order", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SWAPWALLET_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}{
"status": "OK"
}{
"status": "ERROR",
"error": {
"codeString": "SWAP_ORDER_EXPIRED",
"message": "Swap order has expired",
"localizedMessage": "قیمتها در بازار تغییر کرده است. لطفا مجددا اقدام کنید."
}
}