Skip to main content

Estimate exchange

Method returns a float exchange estimation. You need to provide the request with currency pair (from, to) and the amount user is going to exchange.

info

Estimated amountTo property includes Changelly plus partner extra fee. However, amountTo doesn't include the network fee. To calculate the estimated amount to show user, deduct networkFee value from amountTo.

HTTP request

post
/v2/#getExchangeAmount

Request

Header parameters

Requires authentification.

Body parameters

Requires JSON-RPC 2.0 protocol request body.

info

You can set params as:

  • an object to get result for 1 currency pair
  • an array of 1 object to get result even if you request only 1 currency pair
  • an array of objects when requesting more than 1 currency pair
If you set params as an object without an array, getExchangeAmount will return an error.
If you set params as an object in an array, getExchangeAmount will return an array without an invalid currency pair or an empty array.

The params parameter schema:

NameTypeRequiredDescription
fromstringtruePayin currency ticker (in lowercase).
tostringtruePayout currency ticker (in lowercase).
amountFromstringtrueAmount of currency that user is going to send.
userMetadatastringfalseEscaped JSON.
You can use userMetadata to include any additional parameters for customization purposes.
To use this feature, please contact us at [email protected].
Sample request payload with the params as an object with 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": {
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
}
}
Sample request payload with the params as an array of 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": [
{
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
}
]
}
Sample request payload with the params as an array of 2 pairs
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": [
{
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
},
{
"from": "btc",
"to": "ltc",
"amountFrom": "1"
}
]
}
Sample request payload with the userMetadata
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": {
"from": "ltc",
"to": "eth",
"amountFrom": "3.99",
"userMetadata": "{\"param1\": 50, \"param2\": \"string\", \"param3\": \"50.5189\"}"
}
}
Sample cURL
curl --location --request POST 'https://api.changelly.com/v2' \
--header 'X-Api-Key: {{apiKey}}' \
--header 'X-Api-Signature: {{sign}}' \
--data-raw '{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": {
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
}
}'

Response

Response parameters

Requires JSON-RPC 2.0 protocol response body.

The result parameter schema:

NameTypeDescription
fromstringPayin currency ticker.
tostringPayout currency ticker.
networkFeestringCommission taken by the network from the amount sent to the user. Displayed in pay-out currency.
amountFromstringAmount of currency the user is going to send.
amountTostringEstimated amount of currency before withholding networkFee.
To calculate the estimated amount that the user will get, you should deduct the networkFee value from amountTo.
maxstringMaximum exchangeable amount.
maxFromstringMaximum payin amount for which we would be able to perform the exchange.
maxTostringMaximum payout amount for which we would be able to perform the exchange.
minstringMinimum exchangeable amount.
minFromstringMinimum payin amount for which we would be able to perform the exchange.
minTostringMinimum payout amount for which we would be able to perform the exchange.
visibleAmountstringThe amount that includes partner extra fee.
ratestringExchange rate before withholding any fees.
feestringExchange fee in payout currency.
Sample response with the params as an object with 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"result": [
{
"from": "ltc",
"to": "eth",
"networkFee": "0.00180019",
"amountFrom": "3.99",
"amountTo": "0.1085994",
"max": "642.0361639",
"maxFrom": "642.0361639",
"maxTo": "17.5791",
"min": "0.19713669",
"minFrom": "0.19713669",
"minTo": "0.00540057",
"visibleAmount": "0.108871578947368421",
"rate": "0.0272861100",
"fee": "0.000272178947368421"
}
]
}
Sample response with the params as an array of 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"result": [
{
"from": "ltc",
"to": "eth",
"networkFee": "0.0019658900000000000000",
"amountFrom": "3.99",
"amountTo": "0.16041285",
"max": "1300",
"maxFrom": "1300",
"maxTo": "52.46028908",
"min": "1.54648",
"minFrom": "1.54648",
"minTo": "0.06240676",
"visibleAmount": "0.16081488721804511278",
"rate": "0.04030448301204138164",
"fee": "0.00040203721804511278195"
}
]
}
Sample response with the params as an array of 2 pairs
application/json
{
"jsonrpc": "2.0",
"id": "test",
"result": [
{
"from": "ltc",
"to": "eth",
"networkFee": "0.0019658900000000000000",
"amountFrom": "3.99",
"amountTo": "0.16041285",
"max": "1300",
"maxFrom": "1300",
"maxTo": "52.46028908",
"min": "1.54648",
"minFrom": "1.54648",
"minTo": "0.06240676",
"visibleAmount": "0.16081488721804511278",
"rate": "0.04030448301204138164",
"fee": "0.00040203721804511278195"
},
{
"from": "btc",
"to": "ltc",
"networkFee": "0.0016150300000000000000",
"amountFrom": "1",
"amountTo": "417.98039400",
"max": "3.53734108",
"maxFrom": "3.53734108",
"maxTo": "1300",
"min": "0.00420803",
"minFrom": "0.00420803",
"minTo": "1.54648",
"visibleAmount": "419.65903012048192771084",
"rate": "419.65903012048192771084",
"fee": "1.67863612048192771084336"
}
]
}

Error response

Error response parameters

Check the error response schema.

Error codes

CodeMessageDescription
-32600Error: You reached requests limit {limit} rpsYou have been sending more than 10 requests per second.
-32602Invalid currency: {currency} temporary disabledThis currency is currently disabled.
-32602Invalid amount for pair {from_currency}->{to_currency}The attempt to exchange more currency than a maximal amount or less than the minimal one.
-32602Invalid amount for pair {from_currency}->{to_currency}. {limit_type} amount is {limit} {currency}The attempt to exchange currency out of limits. {limit_type} is a “Minimal“ or “Maximum“ value.
-32602Invalid currency: {currency} is temporary disabled on API as output currencyThis currency is currently disabled on API as an output currency.
-32602Invalid currency: {currency} is temporary disabled on API as input currencyThis currency is currently disabled on API as an input currency.
-32602Invalid currency: {currency} not foundThis currency is not listed on Changelly or the ticker is invalid.
-32602Parameter {param} is invalidYou've specified an invalid parameter.
-32603Internal Error or ErrorMost likely, the problem is on our side. Further investigation is required.