Estimate exchange
POST getExchangeAmount
You need to provide the request with currency pair (from
, to
) and the amount user is going to exchange.
note
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
https://api.changelly.com/v2/#getExchangeAmount
Request
- Request
- Payload
- cURL
Header parameters
Name | Type | Required | Description |
---|---|---|---|
X-Api-Key | string | true | Your API key (SHA256 from Public Key) |
X-Api-Signature | string | true | The query's serialized body signed by your private key according to the RSA-SHA256 method. |
Body parameters
Name | Type | Required | Description |
---|---|---|---|
jsonrpc | string | true | JSON-RPC version. |
id | string | true | Client's custom ID. |
method | string | true | API method name. |
params | object or array of objects | true | Request parameters. You can set params as:
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. |
params
object:
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]. |
Params as object with 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": {
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
}
}
Params as array of 1 pair
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "getExchangeAmount",
"params": [
{
"from": "ltc",
"to": "eth",
"amountFrom": "3.99"
}
]
}
Params as 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"
}
]
}
Params with 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\"}"
}
}
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
- Example
- Success
- Errors
Sample response
Params as 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"
}
]
}
Params as 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"
}
]
}
Params as 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"
}
]
}
Response params
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
result | array of objects | Result. |
result
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. |
Error schema
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
error | object | Possible errors. |
»code | integer | Error code. |
»message | string | Error message. |
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. |