'CoinGecko exchange rates conversion

I already seen the CoinGecko documentation but it does not contain explaination or in depth explaination on their API Documentation.

Regarding on CoinGeckos API, their is exchange_rates but it is only applicable for Bitcoin (BTC) to other currencies, my concern is, is there a ways to make any conversion from XRP to AUD base on this response? https://api.coingecko.com/api/v3/exchange_rates

Also they have a link to make conversion but I don't know how they make it work.



Solution 1:[1]

I think I found the solution

The API returns an object with the list of rates:

{
  "rates": {
    "btc": {
      "name": "Bitcoin",
      "unit": "BTC",
      "value": 1,
      "type": "crypto"
    },
    "eth": {
      "name": "Ether",
      "unit": "ETH",
      "value": 15.108,
      "type": "crypto"
    },
    "ltc": {
      "name": "Litecoin",
      "unit": "LTC",
      "value": 243.364,
      "type": "crypto"
    },
    "bch": {
      "name": "Bitcoin Cash",
      "unit": "BCH",
      "value": 66.392,
      "type": "crypto"
    },
    "bnb": {
      "name": "Binance Coin",
      "unit": "BNB",
      "value": 114.554,
      "type": "crypto"
    },
    "eos": {
      "name": "EOS",
      "unit": "EOS",
      "value": 8665.498,
      "type": "crypto"
    },
    "xrp": {
      "name": "XRP",
      "unit": "XRP",
      "value": 50657.684,
      "type": "crypto"
    },
    "xlm": {
      "name": "Lumens",
      "unit": "XLM",
      "value": 131419.329,
      "type": "crypto"
    },
   ...
}

So inorder to get the currency value for XRP to AUD, it needs to divide the 2 values, example AUD 45686.711 / XRP 50657.684 where the dividen should be the highest value

Sorry my bad, the conversion should be $to / $from there is no dividen format

Can someone confirm this as a solution?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1