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

Requests and responses

Base URL, JSON format, the response envelope, Money objects, timestamps, pagination and safe retries: the conventions every SwapWallet endpoint follows.

Every endpoint follows the same conventions. Learn them once here and the whole reference reads the same way.

Base URL and format

Every path in this reference is relative to https://swapwallet.app/api. Requests must use HTTPS.

  • Send bodies as JSON with Content-Type: application/json.
  • Responses are JSON in UTF-8.
  • Enum values are upper case: USDT, TRON, SUCCEED.
  • Query parameters that take a list are repeated: types=TRADE&types=TRANSFER.

The response envelope

Every response is wrapped the same way. status is OK or ERROR. On success the data is in result; endpoints that only confirm an action return { "status": "OK" } with no result.

JSON
{
  "status": "OK",
  "result": {
    "token": "USDT",
    "amount": { "number": "1149.5", "unit": "USDT" }
  }
}

A failed request has an HTTP error status and an error object instead of result. Errors explains every field.

JSON
{
  "status": "ERROR",
  "error": {
    "codeString": "VALIDATION_FAILED",
    "message": "Request validation failed",
    "localizedMessage": "اطلاعات درخواست معتبر نیست"
  }
}

Amounts are Money objects

An amount is never a bare number. It is a Money object: the value as a decimal string, and its unit.

JSON
{ "number": "0.000125", "unit": "BTC" }
  • number is a string so that no precision is lost: "0.1" stays exactly 0.1. Parse it with a decimal type (BigDecimal, Python’s Decimal, decimal.js), never a float, and send amounts back as strings.
  • unit is a token symbol (USDT, TON, BTC, …), IRT for the Toman, or USD for a dollar value.
  • Toman amounts are whole Tomans, not rials: { "number": "1500000", "unit": "IRT" } is one and a half million Tomans.

Dates and times

Timestamps are ISO 8601 strings in UTC, such as "2026-11-23T10:15:09Z". The one exception is the timestamp field of transactions in List transactions, which is Unix time in milliseconds. Date filters you send are ISO 8601 as well.

Pagination

List transactions returns its results in pages and moves through them by transaction ID, which stays correct while new transactions keep arriving. Results come newest first: for the next, older page, pass the smallest id you received as beforeId. To read forward in time, send sortDir=ASC and pass the largest id as afterId. Keep going while hasNext is true.

JSON
{
  "status": "OK",
  "result": {
    "hasNext": true,
    "data": [ { "id": 3051234, … }, { "id": 3051210, … } ]
  }
}

Retrying safely

Reading is always safe to repeat. Requests that move money are not: if a withdrawal or swap times out, the first attempt may still have gone through. Before you send it again, look for the transaction in List transactions.