Convert

On this page, we’ll dive into the different convert asset endpoints you can use to manage convert asset transactions programmatically. You can convert your crypto balance into fiat assets.

The convert model

The convert model is the data structure that represents a convert asset transaction in WePay. The following attributes are associated with the convert model:

Properties

FieldTypeDescription
convertIdstring

Unique identifier for the convert transaction.

userIdstring

Unique identifier for the user making the convert.

inputobject

Details of the input asset.

input.assetTypestring

The type of asset (e.g., fiat or crypto).

input.currencystring

The currency used for the input asset (e.g., usdt-tron).

input.amountfloat

The initial amount of the convert in the input currency.

input.amountMinusFeefloat

The final amount after deducting the fee of the convert in the input currency.

outputobject

Details of the output asset.

output.assetTypestring

The type of asset (e.g., fiat or crypto).

output.currencystring

The currency used for the output asset (e.g., IDR).

output.amountfloat

The initial amount of the convert in the output currency.

output.amountMinusFeefloat

The final amount after deducting the fee of the convert in the output currency.

exchangeRatefloat

The exchange rate applied to the convert.

createdAtstring

Timestamp when the convert was created.

updatedAtstring

Timestamp when the convert was last updated.


GET/v1/convert/estimate

Estimate Asset Conversion

This endpoint is used to estimate the conversion from an input currency to an output currency. It provides an estimated amount that will be received after the conversion, taking into account the current exchange rate and any applicable fees.

Query Params attributes

FieldTypeDescription
inputCurrencystring

The crypto currency input of the convert.

inputAmountfloat

The amount of the convert in the input currency. This is required if outputAmount is not provided.

outputCurrencystring

The fiat currency output of the convert.

outputAmountfloat

The amount of the convert in the output currency. This is required if inputAmount is not provided.

markupRatePercentagefloat

The amount of markup rate percentage applied to the convert transaction. Optional, default is 0.

Request

GET
/v1/convert/estimate
curl -X GET "https://staging.wepay.to/v1/convert/estimate?inputCurrency=usdt-tron&inputAmount=100&outputCurrency=IDR" \
-H "X-Signature: YOUR_SIGNATURE" \
-H "X-Timestamp: YOUR_TIMESTAMP" \
-H "X-Client-ID: YOUR_CLIENT_ID"

Response

{
      "statusCode": 200,
      "message": "Convert estimation success",
      "data": {
        "quoteId": "51b0d358-dcbc-4ae1-998c-33e6e7b6d3e9",
        "input": {
            "currency": "usdt-tron",
            "type": "crypto",
            "amount": 100
        },
        "output": {
            "currency": "IDR",
            "type": "fiat"
        },
          "estimate": {
              "rate": {
                "crypto": 0.00006073043654,
                "fiat": 16466.208,
              },
              "convertedAmount": 1646620.8,
              "fee": 5000,
              "totalConvertedAmount": 1641620.8,
              "markupRatePercentage": 0
          }
        }
  }

POST/v1/convert

Asset Conversion

This endpoint is used to convert an input amount of cryptocurrency to a fiat output currency. It requires specifying the input currency, input amount, and the desired output currency. The endpoint will process the conversion based on the current exchange rate and applicable fees, and return the converted amount in the output currency.

Read the statusCode field in the response body rather than the HTTP status code.

Ensure the input.currency and output.currency is a valid asset currency code and input.amount or output.amount is a positive number.

Required attributes

FieldTypeDescription
inputobject

The input details of the convert transaction.

input.currencystring

The crypto currency of the input (e.g., usdt-tron).

input.amountfloat

The amount of the input. This is required if output.amount is not provided.

outputobject

The output details of the convert transaction.

output.currencystring

The currency of the output (e.g., IDR).

output.amountfloat

The amount of the output. This is required if input.amount is not provided.

Optional attributes

FieldTypeDescription
quoteIdstring

This can be used to specify the quote ID for the deposit-convert transaction. Got from Convert estimation endpoint.

Request

POST
/v1/convert
curl --location \
https://staging.wepay.to/v1/convert \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "input": {
        "currency" : "usdt-tron",
        "amount": 100
    },
    "output": {
        "currency" : "IDR"
    }
}'

Response

{
  "statusCode": 200,
  "message": "Conversion executed successfully",
  "data": {
    "convertId": "51b0d358-dcbc-4ae1-998c-33e6e7b6d3e9",
    "input": {
        "currency": "usdt-tron",
        "type": "crypto",
        "amount": 100
    },
    "output": {
        "currency": "IDR",
        "type": "fiat"
    },
    "result": {
        "rate": {
          "crypto": 0.00006073043654,
          "fiat": 16466.208,
        },
        "convertedAmount": 1646620.8,
        "fee": 5000,
        "totalConvertedAmount": 1641620.8,
        "markupRatePercentage": 0
    }
  }
}

HTTP Status 400 Example

Error Response

{
    "statusCode": 400,
    "error": "Not Found",
    "message": "insufficient input balance"
}

Did this page help you ship?