> For the complete documentation index, see [llms.txt](https://docs.oxapay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oxapay.com/api-reference/swap/swap-calculate.md).

# Swap Calculate

This endpoint allows you to instantly calculate how much cryptocurrency you'll receive when swapping one currency for another. Designed for ease of use, it provides real-time rates to ensure accurate calculations. Simply integrate this feature into your app to access the latest rates anytime. Whether you're buying or selling, this endpoint simplifies the process by giving you quick and precise swap amounts for your desired currency.

## POST /general/swap/calculate

>

```json
{"openapi":"3.0.0","info":{"title":"Swaps","version":"1.0.0"},"servers":[{"url":"https://api.oxapay.com/v1"}],"security":[],"paths":{"/general/swap/calculate":{"post":{"operationId":"swapCalculate","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["from_currency","to_currency","amount"],"properties":{"from_currency":{"type":"string","description":"Specify the currency symbol you want to swap from."},"to_currency":{"type":"string","description":"Specify the currency symbol you want to swap to."},"amount":{"type":"number","format":"decimal","description":"Specify the amount of currency you want to swap."}}}}}},"responses":{"200":{"description":"Successful operation","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"to_amount":{"type":"number","format":"decimal","description":"The amount of the \"to_currency\" received after the swap, represented with high precision."},"rate":{"type":"number","format":"decimal","description":"The swap rate between the \"from_currency\" and \"to_currency\" at the time of the request."},"amount":{"type":"number","format":"decimal","description":"The amount of the \"from_currency\" being swapped, represented with high precision."}}},"message":{"type":"string","description":"A message containing additional information about the result of the request."},"error":{"type":"object","description":"An object that provides details about any errors that occurred.","nullable":true,"properties":{"type":{"type":"string","description":"Type of the error"},"key":{"type":"string","description":"Key related to the error"},"message":{"type":"string","description":"Error message"}}},"status":{"type":"integer","description":"The status of the request response. Typically provided as a numeric code (e.g., 200 for success or other codes for errors)."},"version":{"type":"string","description":"The version of the API being used."}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{}},"message":{"type":"string","description":"A message containing additional information about the result of the request."},"error":{"type":"object","description":"An object that provides details about any errors that occurred.","nullable":true,"properties":{"type":{"type":"string","description":"Type of the error"},"key":{"type":"string","description":"Key related to the error"},"message":{"type":"string","description":"Error message"}}},"status":{"type":"integer","description":"The status of the request response. Typically provided as a numeric code (e.g., 200 for success or other codes for errors)."},"version":{"type":"string","description":"The version of the API being used."}}}}}}},"tags":["Swap-calculate"],"parameters":[{"in":"header","name":"general_api_key","required":true,"schema":{"type":"string"},"description":"Your General API Key for authentication and authorization."},{"in":"header","name":"Content-Type","required":true,"schema":{"type":"string","default":"application/json"}}]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.oxapay.com/api-reference/swap/swap-calculate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
