# calculateTrade

> POST /trades/calculateTrade returns the rate and amounts for a currency pair, with optional send_value to get the receive amount and availability.

Source: https://docs.yellowchanger.com/calculateTrade

Returns exchange rate and details for a specific currency pair

**POST** `https://api.yellowchanger.com/trades/calculateTrade`

## Headers

| Name | Value |
| --- | --- |
| Content-Type | application/json |
| Y_API_KEY | Public API Key |
| [Signature](https://docs.yellowchanger.com/signature.md) | HMAC SHA256 of Body |

## Body

| Name | Type | Description |  |  |
| --- | --- | --- | --- | --- |
| send_name | string | Currency being sent |  |  |
| send_network | string | Network of currency being sent |  |  |
| get_name | string | Currency being received |  |  |
| get_network | string | Network of currency being received |  |  |
| send_value | _optional_ |  | number | Amount to send. If provided, get_value and available will be included in the response |
| commission | _optional_ |  | float | Additional commission in percent, which is considered your profit (default 0.5) |

## Response

**200**

```json
{
          "send": {
                    "name": "Monero",
                    "precision": 8,
                    "min_deposit": 0.001
          },
          "get": {
                    "name": "Litecoin",
                    "precision": 8,
                    "min_withdraw": 0.0198,
                    "network_fee": 0.006
          },
          "pair": {
                    "min_deposit": 0.00397993,
                    "min_withdraw": 0.01980001,
                    "network_fee": 0.006,
                    "rate": 6.4825359,
                    "get_value": 0.00696507,
                    "available": false
          }
}
```

**40X**

```json
{
          "statusCode": 400,
          "message": "Some error message"
}
```

## Example

**JavaScript**

```javascript
const options = {
          method: "POST",
          headers: {
                    "Content-Type": "application/json",
                    Y_API_KEY: "Your API Key",
                    Signature: "02fe657ed8405c521fb3d5e3fd9ef7ff92f849c9ab976dcbe25e6ec4aacae0ed",
          },
          body: '{"send_name":"XMR","send_network":"XMR","get_name":"LTC","get_network":"LTC","send_value":0.002}',
};
fetch("https://api.yellowchanger.com/trades/calculateTrade", options)
          .then((e) => e.json())
          .then((e) => console.log(e))
          .catch((e) => console.error(e));
```

**Python**

```python
import requests

url = "https://api.yellowchanger.com/trades/calculateTrade"

payload = {
    "send_name": "XMR",
    "send_network": "XMR",
    "get_name": "LTC",
    "get_network": "LTC",
    "send_value": 0.002
}
headers = {
    "Content-Type": "application/json",
    "Y_API_KEY": "Your API Key",
    "Signature": "02fe657ed8405c521fb3d5e3fd9ef7ff92f849c9ab976dcbe25e6ec4aacae0ed"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
```

## Related

- [destinationsList](https://docs.yellowchanger.com/destinationsList.md): Returns all possible exchange destinations
- [ratesInDirection](https://docs.yellowchanger.com/ratesInDirection.md): Returns rates in a certain direction
- [createTrade](https://docs.yellowchanger.com/createTrade.md): Create new trade and returns trade info

---

All methods: https://docs.yellowchanger.com/introduction.md · Index: https://docs.yellowchanger.com/llms.txt · Whole documentation in one file: https://docs.yellowchanger.com/llms-full.txt
