Skip to main content

Using API for swap

Postman collection with all endpoints - Using_API_for_swap.postman_collection.zip

Login to account

You need to get api keys for your account and login to your account in order to get the token necessary for swap estimate.

post
Endpoint POST /api/public/auth

Parameters

Request body

  • publicKey

    *

    string

  • privateKey

    *

    string

  • walletId

    *

    string

  • passphrase

    *

    string

Responses

  • 200:OK
    {
    token: "String"
    }
  • 200:Example
    {
    token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMDI5MDg0ZDA4NmM2MDExMzc3ODFlMiIsInVzZXIiOiI2MDlhNjM0MGU1ZTFjZjAyMTU2ZDBkZjciLCJpYXQiOjE2OTgyNDU5NTcsImV4cCI6MTY5ODMzMjM1N30.ogoBh6UolGWJUy0bOcNPjNNqPqstoj8ld_u3siUSEQU"
    }

Swap estimate

get
Endpoint POST /api/public/swap/estimate

Parameters

Query

  • fromId

    *

    string

  • toId

    *

    string

  • amount

    *

    string

  • type

    *

    string

    Available values: (fixed, float)

  • sort

    *

    string

    Available values: (rate, duration)

Responses

  • 200:OK
    {
    "status": "string",
    "data": [
    {
    "id": "string",
    "supportRate": "number",
    "duration": "string",
    "min": "number",
    "max": "number",
    "fixed": "boolean",
    "partner": "string",
    "exists": "boolean",
    "fromAmount": "number",
    "fromCurrency": "string",
    "fromNetwork": "string",
    "toAmount": "number",
    "toCurrency": "string",
    "toNetwork": "string"
    }
    ]
    }
  • 200:Example
    {
    "status": "success",
    data: [
    {
    "partner": "fixedfloat",
    "fromAmount": 0.001507298809,
    "toAmount": 26.8,
    "fromCurrency": "eth",
    "fromNetwork": "arbitrum",
    "toCurrency": "trx",
    "toNetwork": "trx",
    "supportRate": 3,
    "duration": "1-3",
    "fixed": false,
    "min": 0.00070025,
    "max": 55.2858833,
    "exists": true,
    "id": ""
    },
    ...
    ]
    }

Best offer

get
Endpoint POST /api/public/swap/best-offer

Parameters

Query

  • fromId

    *

    string

  • toId

    *

    string

  • amount

    *

    string

  • type

    *

    string

    Available values: (fixed, float)

Responses

  • 200:OK
    {
    "status": "string",
    "data": {
    "id": "string",
    "supportRate": "number",
    "duration": "string",
    "min": "number",
    "max": "number",
    "fixed": "boolean",
    "partner": "string",
    "exists": "boolean",
    "fromAmount": "number",
    "fromCurrency": "string",
    "fromNetwork": "string",
    "toAmount": "number",
    "toCurrency": "string",
    "toNetwork": "string"
    }
    }
  • 200:Example
    {
    "status": "success",
    "data": {
    "partner": "fixedfloat",
    "fromAmount": 0.001507298809,
    "toAmount": 26.59,
    "fromCurrency": "eth",
    "fromNetwork": "arbitrum",
    "toCurrency": "trx",
    "toNetwork": "trx",
    "supportRate": 3,
    "duration": "1-3",
    "fixed": false,
    "min": 0.00070959,
    "max": 55.4090295,
    "exists": true,
    "id": ""
    }
    }

Login to wallet

You need to log in to your wallet to get the token necessary for swap.

post
Endpoint POST /api/public/auth

Parameters

Request body

  • walletId

    *

    string

  • passphrase

    *

    string

  • publicKey

    *

    string

  • privateKey

    *

    string

Responses

  • 200:OK
    {
    token: "String"
    }
  • 200:Example
    {
    token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMDI5MDg0ZDA4NmM2MDExMzc3ODFlMiIsInVzZXIiOiI2MDlhNjM0MGU1ZTFjZjAyMTU2ZDBkZjciLCJpYXQiOjE2OTgyNDU5NTcsImV4cCI6MTY5ODMzMjM1N30.ogoBh6UolGWJUy0bOcNPjNNqPqstoj8ld_u3siUSEQU"
    }

Swap create

post
Endpoint POST /api/public/swap/create

Parameters

Request body

  • currencyFromId

    *

    string

  • toId

    *

    string

  • currencyToId

    *

    string

  • amount

    *

    number

  • partner

    *

    string

  • fixed

    *

    boolean

  • rateId

    *

    string

  • password

    string

  • sign

    string

    base64 format

Responses

  • 200:OK
    {
    "status": "string",
    "data": {
    "id": "string",
    "exchangeId": "string"
    }
    }
  • 200:Example
    {
    "status": "success",
    "data": {
    "id": "653933e0c42d5826fb293dd1",
    "exchangeId": "M7FwLL3ABWy2"
    }
    }

Swap history

search sort order currencyFromId currencyToId

get
Endpoint POST /api/public/swap/history

Parameters

Query

  • search

    string

  • sort

    string

    Default value: date

  • order

    string

    Available values: ASC (default), DESC

  • currencyFromId

    number

  • currencyToId

    string

Responses

  • 200:OK
    {
    "success": "string",
    "data": {
    "page": "number",
    "pages": "number",
    "countItems": "number",
    "entities": [
    {
    "id": "string",
    "exchangeId": "string",
    "partner": "string",
    "fixed": "boolean",
    "typeNetwork": "string",
    "status": "boolean",
    "systemStatus": "string",
    "convertRate": "number",
    "from": {
    "id": "string",
    "address": "string",
    "amount": {
    "value": "number",
    "usd": "number"
    },
    "currency": {
    "id": "string",
    "name": "string"
    },
    "paymentId": "string",
    "hash": "string"
    },
    "to": {
    "id": "string",
    "address": "string",
    "amount": {
    "value": "number",
    "usd": "number"
    },
    "currency": {
    "id": "string",
    "name": "string"
    },
    "paymentId": "string",
    "hash": "string"
    },
    "merchant": "string",
    "user": "string",
    "rateId": "string",
    "createdAt": "2023-10-25T16:27:25.948Z",
    "updatedAt": "2023-10-25T16:27:25.948Z"
    }
    ]
    }
    }
  • 200:Example
    {
    status: "success",
    data: {
    page: 1,
    pages: 1,
    countItems: 1,
    entities: [
    {
    exchangeId: "M7FwLL3ABWy2",
    partner: "fixedfloat",
    fixed: false,
    typeNetwork: "mainnet",
    status: true,
    systemStatus: "Done",
    convertRate: 17286.013772111106,
    from: {
    id: "65393170c42d5826fb2937e5",
    address: "0xBdFD77602F9054D58348AD62bb98656A989DacD1",
    amount: {
    value: 0.00134039,
    usd: 2.41,
    },
    currency: {
    id: "648867f0636df554e46ed797",
    name: "ETH",
    },
    paymentId: "653933e0c42d5826fb293dae",
    hash: "0x1854cdcc7219ee93afd04ea3a6e63842a102b8bb2747253789dcb2a5fa40e12a",
    },
    to: {
    id: "652fc1b70fbdfb585e7c9249",
    address: "TDKSMESvxjsRjYY9iq2y41hrLZGPYZMsxR",
    amount: {
    value: 23.17,
    usd: 2.17,
    },
    currency: {
    id: "61641091597bd03988be5c62",
    name: "TRX",
    },
    paymentId: "6539358569d6e4f0ae249f96",
    hash: "fa1ff257cd29c189d42f10636d757c25f61fb40b47d73fb981ce29eb8ab06cb0",
    },
    merchant: "62029084d086c601137781e2",
    user: "609a6340e5e1cf02156d0df7",
    rateId: "",
    swapType: "swapSpace",
    createdAt: "2023-10-25T15:27:28.741Z",
    updatedAt: "2023-10-25T15:35:00.450Z",
    _id: "653933e0c42d5826fb293dd1",
    },
    ],
    },
    }