Estimate a float-rate exchange
posthttps://api.criptointercambio.com/v2/#getExchangeAmountRetrieves a float-rate exchange estimation for the provided amount.
The estimated amountTo property includes Cripto InterCambio and partner extra fees, but not the network one. To calculate the exact estimated amount for users, deduct the networkFee value from the amountTo.
Request
Header parameters
Requires authentication headers.
Body parameters
Consists of a JSON-RPC 2.0 protocol request object.
How to set the params
The params has several setting options:
- an object to get the result for one currency pair.
- an array of one object to get the result, even if you request only one currency pair.
- an array of objects to get the result for more than one currency pair.
If the params is an object without an array, getFixRateForAmount returns an error.
If the params is an object in an array, getFixRateForAmount returns an array without an invalid currency pair or an empty array.
The params schema:
| Name | Type | Required | Description |
|---|---|---|---|
amountFrom | string | true | The amount for sending. |
from | string | true | The payin currency ticker. Enter in lowercase. |
to | string | true | The payout currency ticker. Enter in lowercase. |
userMetadata | string | false | The escaped JSON. Info The userMetadata param can include any additional settings for customization. To use this feature, contact us at [email protected]. |
Sample request
{
"jsonrpc": "2.0",
"id": "exampleCustomIdValue",
"method": "getExchangeAmount",
"params": {
"amountFrom": "56",
"from": "xrp",
"to": "atom",
"userMetadata": "{\"param1\": 50, \"param2\": \"string\", \"param3\": \"50.5189\"}"
}
}
Response
Successful response
Consists of a JSON-RPC 2.0 protocol response object.
The result schema:
| Name | Type | Description |
|---|---|---|
amountFrom | string | The amount for exchange. |
amountTo | string | The estimated amount before withholding networkFee. WarningTo calculate the estimated amount, deduct the networkFee value from the amountTo. |
fee | string | The exchange fee in the payout currency. |
from | string | The payin currency ticker. |
to | string | The payout currency ticker. |
max | string | The maximum exchangeable amount. |
maxFrom | string | The maximum exchangeable amount for payin. |
maxTo | string | The maximum exchangeable amount for payout. |
min | string | The minimum exchangeable amount. |
minFrom | string | The minimum exchangeable amount for payin. |
minTo | string | The minimum exchangeable amount for payout. |
networkFee | string | The network commission from a sent amount. Displayed in the payout currency. |
rate | string | The exchange rate before withholding any fees. |
visibleAmount | string | The amount including partner extra fee. |
Sample successful response
{
"jsonrpc": "2.0",
"id": "exampleCustomIdValue",
"result": [
{
"amountFrom": "56",
"amountTo": "46.460934",
"fee": "0.116443",
"from": "xrp",
"to": "atom",
"max": "23661.302649",
"maxFrom": "23661.302649",
"maxTo": "19738.270532",
"min": "2.9154",
"minFrom": "2.9154",
"minTo": "2.432031",
"networkFee": "0.791365",
"rate": "0.831738875000000000",
"visibleAmount": "46.577377"
}
]
}
Error response
Consists of a JSON-RPC 2.0 protocol error response object.
Sample error response
{
"jsonrpc": "2.0",
"id": "exampleCustomIdValue",
"error": {
"code": -32602,
"message": "Invalid amount for pair btc->eth"
}
}
Error codes
| Code | Message | Description |
|---|---|---|
-32600 | Error: You reached requests limit {limit} rps | RPS is out of the limit. |
-32602 | Invalid amount for pair {from_currency}->{to_currency} | The currency amount for exchange is above the maximum amount or below the minimum amount. |
Invalid currency: {currency} temporary disabled | Cripto InterCambio temporarily disabled this currency. | |
Invalid currency: {currency} is temporary disabled on API as input currency | Cripto InterCambio temporarily disabled this currency for payin. | |
Invalid currency: {currency} is temporary disabled on API as output currency | Cripto InterCambio temporarily disabled this currency for payout. | |
Invalid currency: {currency} not found |
| |
Parameter {param} is invalid | The specified request param is invalid. | |
-32603 |
| Mostly, this is a technical issue on our side. Requires further investigation. |