Estimate a fixed-rate exchange
posthttps://api.criptointercambio.com/v2/#getFixRateForAmountRetrieves a fixed-rate exchange estimation for the provided amount.
Ensure your amount corresponds with the minimum and maximum amounts. To fetch limits for a current pair, use getPairsParams (deprecated).
If the amount does not correspond with the minimum and maximum amounts, getFixRateForAmount retrieves an error.
The getFixRateForAmount method requires setting amountFrom or amountTo despite their optionality. If you provide none or both, the request retrieves an error.
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, the getFixRateForAmount retrieves an error.
If the params is an object in an array, the getFixRateForAmount retrieves an array without an invalid currency pair or an empty array.
The params schema:
| Name | Type | Required | Description |
|---|---|---|---|
amountFrom | string | false | The amount for the fixed-rate exchange. |
amountTo | string | false | The amount for receiving. |
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": "getFixRateForAmount",
"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 fixed-rate exchange. |
amountTo | string | The amount for receiving. |
expiredAt | timestamp | The fixed rate expiration time. |
from | string | The payin currency ticker. |
to | string | The payout currency ticker. |
id | string | The exchange rate ID . You should use id for 1 minute. It is enough to start the exchange. After expiration, id is not actual for creation. InfoThe id param requires storage on your side. createFixTransaction uses it as rateId while calling. |
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. |
result | string | The exchange rate before withholding the networkFee. Warning To calculate the final amount that the user will get, multiply the amount that the user wants to send to the result and deduct the value of the networkFee. |
Sample successful response
{
"jsonrpc": "2.0",
"id": "exampleCustomIdValue",
"result": [
{
"amountFrom": "56",
"amountTo": "44.189863",
"expiredAt": 768479611,
"from": "xrp",
"to": "atom",
"id": "%WP*************doL@3",
"max": "3715.334407",
"maxFrom": "3715.334407",
"maxTo": "3100.000000",
"min": "37.842952",
"minFrom": "37.842952",
"minTo": "31.575395",
"networkFee": "0.002431",
"result": "0.789148118177"
}
]
}
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 bth->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 amount for pair {from_currency}->{to_currency}. {limit_type} amount is {limit} {currency} | The currency amount for exchange is out of the limits. {limit_type} is a “Minimal“ or “Maximum“ value. | |
Invalid currency: {currency} temporary disabled | Cripto InterCambio temporarily disabled this currency. | |
Invalid currency: {currency} temporary disabled for fix rate transactions | Cripto InterCambio temporarily disabled this currency for fixed-rate transactions. | |
Invalid currency: {currency} is temporary disabled on API as input currency | Cripto InterCambio temporarily disabled this currency as a payin currency. | |
Invalid currency: {currency} is temporary disabled on API as output currency | Cripto InterCambio temporarily disabled this currency as a payout currency. | |
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. |