Module: Coincap::Rates

Defined in:
lib/coincap/rates.rb

Overview

All prices on the CoinCap API are standardized in USD (United States Dollar). To make translating to other values easy, CoinCap now offers a Rates endpoint. We offer fiat and top cryptocurrency translated rates. Fiat rates are available through OpenExchangeRates.org.

Constant Summary collapse

URI_API =
"#{BASE_URI}#{VERSION_API}/rates"

Class Method Summary collapse

Class Method Details

.listHash

Returns a list of all rates.

{
  "data": [
    {
      "id": "barbadian-dollar",
      "symbol": "BBD",
      "currencySymbol": "$",
      "type": "fiat",
      "rateUsd": "0.5000000000000000"
    },
  ...
  ],
  "timestamp": 1536347807471
}

Returns:

  • (Hash)


30
31
32
# File 'lib/coincap/rates.rb', line 30

def self.list
  Helper.fetch_data(URI_API)
end

.single(asset_id) ⇒ Hash

Returns a single rate.

{
  "data": {
    "id": "bitcoin",
    "symbol": "BTC",
    "currencySymbol": "₿",
    "type": "crypto",
    "rateUsd": "6444.3132749056076909"
  },
  "timestamp": 1536347871542
}

Parameters:

  • asset_id (String)

    The asset id (bitcoin)

Returns:

  • (Hash)


49
50
51
# File 'lib/coincap/rates.rb', line 49

def self.single(asset_id)
  Helper.fetch_data("#{URI_API}/#{asset_id}")
end