Skip to main content

Estimate a fixed-rate exchange


posthttps://api.criptointercambio.com/v2/#getFixRateForAmount

Retrieves a fixed-rate exchange estimation for the provided amount.

info

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.

warning

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:

NameTypeRequiredDescription
amountFromstringfalseThe amount for the fixed-rate exchange.
amountTostringfalseThe amount for receiving.
fromstringtrueThe payin currency ticker. Enter in lowercase.
tostringtrueThe payout currency ticker. Enter in lowercase.
userMetadatastringfalseThe 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:

NameTypeDescription
amountFromstringThe amount for fixed-rate exchange.
amountTostringThe amount for receiving.
expiredAttimestampThe fixed rate expiration time.
fromstringThe payin currency ticker.
tostringThe payout currency ticker.
idstringThe 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. Info
The id param requires storage on your side. createFixTransaction uses it as rateId while calling.
maxstringThe maximum exchangeable amount.
maxFromstringThe maximum exchangeable amount for payin.
maxTostringThe maximum exchangeable amount for payout.
minstringThe minimum exchangeable amount.
minFromstringThe minimum exchangeable amount for payin.
minTostringThe minimum exchangeable amount for payout.
networkFeestringThe network commission from a sent amount. Displayed in the payout currency.
resultstringThe 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

CodeMessageDescription
-32600Error: You reached requests limit {limit} rpsRPS is out of the limit.
-32602Invalid 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 disabledCripto InterCambio temporarily disabled this currency.
Invalid currency: {currency} temporary disabled for fix rate transactionsCripto InterCambio temporarily disabled this currency for fixed-rate transactions.
Invalid currency: {currency} is temporary disabled on API as input currencyCripto InterCambio temporarily disabled this currency as a payin currency.
Invalid currency: {currency} is temporary disabled on API as output currencyCripto InterCambio temporarily disabled this currency as a payout currency.
Invalid currency: {currency} not found
  • Cripto InterCambio does not list this currency.
  • The currency ticker is invalid.
Parameter {param} is invalidThe specified request param is invalid.
-32603
  • Internal Error
  • Error
Mostly, this is a technical issue on our side. Requires further investigation.