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
Table 1. Basic exchange rate request parameters
Objects and parameters Description

general
object
strictly required

project_id
integer
strictly required

Project ID obtained from Monetix.

Example: 123

signature
string
strictly required

Signature created after you've specified all the request parameters. For more information about signature generation, see Signature generation and verification.

currency_from
string
strictly required

Code of the initial currency.

Codes of the fiat (government-issued) currencies are specified in the ISO-4217 alpha-3 format.

Codes of cryptocurrencies:

  • BTC—for Bitcoin
  • ETH—for Ether
  • TRX—for Tronix
  • LTC—for Litecoin
  • BNB—for Binance Coin
  • USDT—for Tether
  • USDC—for USD Coin
  • DAI—for Dai
  • POL—for Polygon Ecosystem Token
  • TON—for Toncoin
  • BSCUSD—for Binance Bridged USDT

Example: USD

currency_to
string
strictly required

Code of the conversion currency.

Example: BTC

currency_network_from
string
strictly required

Type of initial currency or blockchain of initial cryptocurrency.

Available currency types:

  • fiat—for fiat (government-issued) currencies

Available blockchains:

  • ethereum—for Ether, Tether or USD Coin
  • bitcoin—for Bitcoin
  • litecoin—for Litecoin
  • bsc—for Binance Coin, Dai or Binance Bridged USDT
  • tron—for Tronix, Tether or USD Coin
  • polygon—for Polygon Ecosystem Token
  • ton—for Toncoin

Example: fiat

currency_network_to
string
strictly required

Type of conversion currency or blockchain of conversion cryptocurrency.

Example: bitcoin

Figure 1. The example of the data from the request to obtain the currency exchange rate information
{
    "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.

Figure 2. The example of the data from the response containing the exchange rate information
{
    "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).

Figure 3. The example of the data from the response containing the information that the exchange rate wasn't found
{
    "status": "error",
    "code": 2284,
    "message": "Currency rate not found"
}