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
| Field | Type | Description |
|---|---|---|
convertId | string | Unique identifier for the convert transaction. |
userId | string | Unique identifier for the user making the convert. |
input | object | Details of the input asset. |
input.assetType | string | The type of asset (e.g., fiat or crypto). |
input.currency | string | The currency used for the input asset (e.g., usdt-tron). |
input.amount | float | The initial amount of the convert in the input currency. |
input.amountMinusFee | float | The final amount after deducting the fee of the convert in the input currency. |
output | object | Details of the output asset. |
output.assetType | string | The type of asset (e.g., fiat or crypto). |
output.currency | string | The currency used for the output asset (e.g., IDR). |
output.amount | float | The initial amount of the convert in the output currency. |
output.amountMinusFee | float | The final amount after deducting the fee of the convert in the output currency. |
exchangeRate | float | The exchange rate applied to the convert. |
createdAt | string | Timestamp when the convert was created. |
updatedAt | string | Timestamp when the convert was last updated. |
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
| Field | Type | Description |
|---|---|---|
inputCurrency | string | The crypto currency input of the convert. |
inputAmount | float | The amount of the convert in the input currency. This is required if |
outputCurrency | string | The fiat currency output of the convert. |
outputAmount | float | The amount of the convert in the output currency. This is required if |
markupRatePercentage | float | The amount of markup rate percentage applied to the convert transaction. Optional, default is 0. |
Request
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
}
}
}
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
| Field | Type | Description |
|---|---|---|
input | object | The input details of the convert transaction. |
input.currency | string | The crypto currency of the input (e.g., usdt-tron). |
input.amount | float | The amount of the input. This is required if |
output | object | The output details of the convert transaction. |
output.currency | string | The currency of the output (e.g., IDR). |
output.amount | float | The amount of the output. This is required if |
Optional attributes
| Field | Type | Description |
|---|---|---|
quoteId | string | This can be used to specify the quote ID for the deposit-convert transaction. Got from Convert estimation endpoint. |
Request
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"
}
