Module: Coincap::AssetsPrice
- Defined in:
- lib/coincap/assets_price.rb
Overview
The asset price is a volume-weighted average calculated by collecting ticker data from exchanges. Each exchange contributes to this price in relation to their volume, meaning higher volume exchanges have more affect on this global price. All values are translated into USD (United States Dollar) and can be translated into other units of measurement through the /rates endpoint.
Constant Summary collapse
- URI_API =
'https://api.coincap.io/v2/assets'
- TIME_INTERVAL =
{ one_minute: 'm1', five_minutes: 'm5', fifteen_minutes: 'm15', thirty_minutes: 'm30', one_hour: 'h1', two_hours: 'h2', six_hours: 'h6', twelve_hours: 'h12', one_day: 'd1' }.freeze
Class Method Summary collapse
-
.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil) ⇒ String
Get all cryptocurrencies.
-
.cryptocurrency(asset_id) ⇒ String
Get single cryptocurrency.
-
.cryptocurrency_history(asset_id, interval) ⇒ String
Get cryptocurrency history price.
-
.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil) ⇒ String
Get price cryptocurrency with markets.
Class Method Details
.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil) ⇒ String
Get all cryptocurrencies
{
"data": [
{
"id": "bitcoin",
"rank": "1",
"symbol": "BTC",
"name": "Bitcoin",
"supply": "17193925.0000000000000000",
"maxSupply": "21000000.0000000000000000",
"marketCapUsd": "119150835874.4699281625807300",
"volumeUsd24Hr": "2927959461.1750323310959460",
"priceUsd": "6929.8217756835584756",
"changePercent24Hr": "-0.8101417214350335",
"vwap24Hr": "7175.0663247679233209"
},
...
],
"timestamp": 1533581088278
}
53 54 55 |
# File 'lib/coincap/assets_price.rb', line 53 def self.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil) Helper.request_to_read_data(URI_API, search: search, ids: ids, limit: limit, offset: offset) end |
.cryptocurrency(asset_id) ⇒ String
Get single cryptocurrency
{
"data": {
"id": "bitcoin",
"rank": "1",
"symbol": "BTC",
"name": "Bitcoin",
"supply": "17193925.0000000000000000",
"maxSupply": "21000000.0000000000000000",
"marketCapUsd": "119179791817.6740161068269075",
"volumeUsd24Hr": "2928356777.6066665425687196",
"priceUsd": "6931.5058555666618359",
"changePercent24Hr": "-0.8101417214350335",
"vwap24Hr": "7175.0663247679233209"
},
"timestamp": 1533581098863
}
78 79 80 |
# File 'lib/coincap/assets_price.rb', line 78 def self.cryptocurrency(asset_id) Helper.request_to_read_data("#{URI_API}/#{asset_id}") end |
.cryptocurrency_history(asset_id, interval) ⇒ String
Get cryptocurrency history price
{
"data": [
{
"priceUsd": "6379.3997635993342453",
"time": 1530403200000
},
...
],
"timestamp": 1533581103627
}
98 99 100 101 |
# File 'lib/coincap/assets_price.rb', line 98 def self.cryptocurrency_history(asset_id, interval) Helper.request_to_read_data("#{URI_API}/#{asset_id}/history", interval: interval.is_a?(Symbol) ? TIME_INTERVAL[interval] : interval) end |
.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil) ⇒ String
Get price cryptocurrency with markets
{
"data": [
{
"exchangeId": "Binance",
"baseId": "bitcoin",
"quoteId": "tether",
"baseSymbol": "BTC",
"quoteSymbol": "USDT",
"volumeUsd24Hr": "277775213.1923032624064566",
"priceUsd": "6263.8645034633024446",
"volumePercent": "7.4239157877678087"
},
...
],
"timestamp": 1539289444052
}
126 127 128 |
# File 'lib/coincap/assets_price.rb', line 126 def self.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil) Helper.request_to_read_data("#{URI_API}/#{asset_id}/markets", limit: limit, offset: offset) end |