Getting currency exchange rate
Overview
While working with the Monetix payment platform, you can clarify current exchange rates for any currency pair that you need. This section describes how to build and submit the exchange rate request and how to process the subsequent response.
You can request:
- the exchange rate of one fiat (government-issued) currency against another fiat currency;
- the exchange rate of one cryptocurrency against EUR or USD, as well as the exchange rate of EUR or USD against a cryptocurrency.
You can not request the exchange rate of one cryptocurrency against another cryptocurrency.
The exchange rate request is executed synchronously, in other words it completes within a single HTTP session and the payment platform responds to a well-formed request with a response that contains the currency exchange rate.
For more information about HTTP response codes, see Integration procedure. For more information about error codes returned by the payment platform, see Operation statuses and response codes.
For more information about currency conversion, see Currency conversion.
Request
The exchange rate request complies with the standard request guidelines described in Integration procedure. The following is the requirement to the contents of the exchange rate request.
HTTP request method | POST |
Request body format | JSON |
API endpoint | /v2/info/currency_crypto_rate |
Objects and parameters | Description | |
---|---|---|
general |
project_id |
Project ID obtained from Monetix. Example: |
signature |
Signature created after you've specified all the request parameters. For more information about signature generation, see Signature generation and verification. | |
currency_from |
Code of the initial currency. Codes of the fiat (government-issued) currencies are specified in the ISO-4217 alpha-3 format. Codes of cryptocurrencies:
Example: |
|
currency_to |
Code of the conversion currency. Example: |
|
currency_network_from |
Type of initial currency or blockchain of initial cryptocurrency. Available currency types:
Available blockchains:
Example: |
|
currency_network_to |
Type of conversion currency or blockchain of conversion cryptocurrency. Example: |
{ "general": { "project_id": 123, "signature": "kUi2x9dKHAVNU0FYldJrxh4ySO/RLUkDJrOcZzUCwX6R/ekpZhkIQg==" }, "currency_from": "USD", "currency_network_from": "fiat", "currency_to": "BTC", "currency_network_to": "bitcoin" }
Response
Response to the exchange rate request complies with the standard guidelines for responses described in Integration procedure.
The response contains the following information:
status
—the status indicating whether the request was successfully received and processed;rate
—exchange rate.
Below you can see an example of the data from the response with the information that 1 USD = 0.0000085 BTC.
{ "status": "success", "rate": "0.0000085" }
If the request was incorrect or the payment platform did not find the exchange rate for the currency pair specified in the request, you will receive a response with a code and a description of the error (for more information about error codes, see Operation statuses and response codes).
{ "status": "error", "code": 2284, "message": "Currency rate not found" }