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
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:
Name | Type | Required | Description |
---|---|---|---|
from | string | true | Payin currency ticker (in lowercase). |
to | string | true | Payout currency ticker (in lowercase). |
amountFrom | string | true | Amount of currency that user is going to send. |
userMetadata | string | false | Escaped 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:
Name | Type | Description |
---|---|---|
from | string | Payin currency ticker. |
to | string | Payout currency ticker. |
networkFee | string | Commission taken by the network from the amount sent to the user. Displayed in pay-out currency. |
amountFrom | string | Amount of currency the user is going to send. |
amountTo | string | Estimated amount of currency before withholding networkFee . To calculate the estimated amount that the user will get, you should deduct the networkFee value from amountTo . |
max | string | Maximum exchangeable amount. |
maxFrom | string | Maximum payin amount for which we would be able to perform the exchange. |
maxTo | string | Maximum payout amount for which we would be able to perform the exchange. |
min | string | Minimum exchangeable amount. |
minFrom | string | Minimum payin amount for which we would be able to perform the exchange. |
minTo | string | Minimum payout amount for which we would be able to perform the exchange. |
visibleAmount | string | The amount that includes partner extra fee. |
rate | string | Exchange rate before withholding any fees. |
fee | string | Exchange 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
Code | Message | Description |
---|---|---|
-32600 | Error: You reached requests limit {limit} rps | You have been sending more than 10 requests per second. |
-32602 | Invalid currency: {currency} temporary disabled | This currency is currently disabled. |
-32602 | Invalid amount for pair {from_currency}->{to_currency} | The attempt to exchange more currency than a maximal amount or less than the minimal one. |
-32602 | Invalid 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. |
-32602 | Invalid currency: {currency} is temporary disabled on API as output currency | This currency is currently disabled on API as an output currency. |
-32602 | Invalid currency: {currency} is temporary disabled on API as input currency | This currency is currently disabled on API as an input currency. |
-32602 | Invalid currency: {currency} not found | This currency is not listed on Changelly or the ticker is invalid. |
-32602 | Parameter {param} is invalid | You've specified an invalid parameter. |
-32603 | Internal Error or Error | Most likely, the problem is on our side. Further investigation is required. |