coingecko_ruby 0.2.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +11 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +44 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +37 -0
- data/README.md +7 -5
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/coingecko_ruby.gemspec +5 -5
- data/fixtures/vcr_cassettes/test_that_it_gets_a_coins_complete_current_data.yml +74 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_a_coins_tickers.yml +99 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_a_derivative_exchange.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_a_specific_exchange_ticker_from_an_exchange.yml +145 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_btc_to_eth_exchange_rate.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_btc_to_usd_exchange_rate.yml +122 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_complete_data_for_an_exchange.yml +72 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_daily_historical_prices_for_one_coin.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_derivative_exchanges.yml +79 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_derivatives.yml +1732 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_derivatives_exchanges_ids_and_names.yml +95 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_event_countries.yml +76 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_event_types.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_exchange_ids_supported_by_coingecko.yml +159 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_exchange_tickers_from_an_exchange.yml +78 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_finance_platforms.yml +95 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_finance_products.yml +100 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_global_crypto_data.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_global_defi_data.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_historical_price_for_one_coin_at_a_previous_date.yml +173 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_hourly_historical_prices_for_one_coin.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_indexes.yml +127 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_indexes_by_market_id_and_coin_id.yml +66 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_indexes_by_market_id_and_index_id.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_indexes_ids.yml +630 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_last_7_days_exchange_volume_from_an_exchange.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_a_coin.yml +169 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_a_coin_in_myr.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_multiple_coins_in_eth.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_minutely_historical_prices_for_one_coin.yml +188 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_ohlc_data_for_one_coin_in_the_last_30_days_in_myr.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_ohlc_data_for_one_coin_in_the_last_7_days.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_price_for_multiple_coins.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_price_for_multiple_coins_in_different_currencies.yml +71 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_price_for_one_coin.yml +122 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_price_for_one_coin_in_a_different_currency.yml +120 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_simple_price_for_one_coin.yml +73 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_status_updates.yml +79 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_status_updates_for_an_exchange.yml +76 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_asset_platforms.yml +80 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_categories.yml +114 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_categories_with_market_data.yml +100 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_supported_coins.yml +143 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_supported_exchanges.yml +79 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_the_list_supported_coins.yml +74 -0
- data/fixtures/vcr_cassettes/test_that_it_gets_trending_searches.yml +77 -0
- data/lib/coingecko_ruby/client.rb +16 -0
- data/lib/coingecko_ruby/client/categories.rb +42 -363
- data/lib/coingecko_ruby/client/coins.rb +32 -31
- data/lib/coingecko_ruby/client/derivatives.rb +154 -0
- data/lib/coingecko_ruby/client/events.rb +84 -0
- data/lib/coingecko_ruby/client/exchanges.rb +51 -1458
- data/lib/coingecko_ruby/client/finance.rb +100 -0
- data/lib/coingecko_ruby/client/indexes.rb +88 -0
- data/lib/coingecko_ruby/client/infos.rb +174 -0
- data/lib/coingecko_ruby/client/prices.rb +85 -269
- data/lib/coingecko_ruby/client/status.rb +1 -1
- data/lib/coingecko_ruby/connection.rb +5 -9
- data/lib/coingecko_ruby/version.rb +1 -1
- metadata +60 -2
@@ -0,0 +1,100 @@
|
|
1
|
+
module CoingeckoRuby
|
2
|
+
class Client
|
3
|
+
module Finance
|
4
|
+
# Fetches the list of finance platforms (e.g. Celsius Network, dYdX) listed in CoinGecko.
|
5
|
+
#
|
6
|
+
# @option options [Integer] :per_page (100) sets the number of results to return per page.
|
7
|
+
# @option options [Integer] :page sets the page for results.
|
8
|
+
#
|
9
|
+
# @return [Array<Hash>] each finance platform's name, category, url, facts (description), and centralized status.
|
10
|
+
#
|
11
|
+
# @example Get all finance platforms.
|
12
|
+
# client.finance_platforms
|
13
|
+
# @example Sample response object (truncated)
|
14
|
+
# [
|
15
|
+
# {
|
16
|
+
# "name"=>"Binance Staking",
|
17
|
+
# "facts"=>"",
|
18
|
+
# "category"=>"CeFi Platform",
|
19
|
+
# "centralized"=>true,
|
20
|
+
# "website_url"=>"https://www.binance.com/en/staking"
|
21
|
+
# },
|
22
|
+
# {
|
23
|
+
# "name"=>"Celsius Network",
|
24
|
+
# "facts"=>"",
|
25
|
+
# "category"=>"CeFi Platform",
|
26
|
+
# "centralized"=>true,
|
27
|
+
# "website_url"=>"https://celsius.network/"
|
28
|
+
# },
|
29
|
+
# {
|
30
|
+
# "name"=>"Cobo",
|
31
|
+
# "facts"=>"",
|
32
|
+
# "category"=>"CeFi Platform",
|
33
|
+
# "centralized"=>true,
|
34
|
+
# "website_url"=>"https://cobo.com/"
|
35
|
+
# }
|
36
|
+
# ]
|
37
|
+
def finance_platforms(**options)
|
38
|
+
get 'finance_platforms', options
|
39
|
+
end
|
40
|
+
|
41
|
+
# @deprecated Use {#finance_platforms} instead
|
42
|
+
def get_finance_platforms(options: {})
|
43
|
+
finance_platforms(**options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Fetches the list of finance products (e.g. Binance Savings, Nexo, Fulcrum) listed in CoinGecko.
|
47
|
+
#
|
48
|
+
# @option options [Integer] :per_page (100) sets the number of results to return per page.
|
49
|
+
# @option options [Integer] :page sets the page for results.
|
50
|
+
# @option options [Integer] :start_at filter results based on the launch date of the product in UNIX timestamp format.
|
51
|
+
# @option options [Integer] :end_at filter results based on the end date of the product in UNIX timestamp format.
|
52
|
+
#
|
53
|
+
# @return [Array<Hash>] each finance product's platform, identifier, supply and borrow rate percentage, and the product duration data.
|
54
|
+
#
|
55
|
+
# @example Get all finance products.
|
56
|
+
# client.finance_products
|
57
|
+
# @example Sample response object (truncated)
|
58
|
+
# [
|
59
|
+
# {"platform"=>"Binance Savings",
|
60
|
+
# "identifier"=>"XTZ001",
|
61
|
+
# "supply_rate_percentage"=>"1.956035",
|
62
|
+
# "borrow_rate_percentage"=>nil,
|
63
|
+
# "number_duration"=>nil,
|
64
|
+
# "length_duration"=>nil,
|
65
|
+
# "start_at"=>0,
|
66
|
+
# "end_at"=>0,
|
67
|
+
# "value_at"=>0,
|
68
|
+
# "redeem_at"=>0},
|
69
|
+
# {"platform"=>"Binance Savings",
|
70
|
+
# "identifier"=>"ZEC001",
|
71
|
+
# "supply_rate_percentage"=>"0.182865",
|
72
|
+
# "borrow_rate_percentage"=>nil,
|
73
|
+
# "number_duration"=>nil,
|
74
|
+
# "length_duration"=>nil,
|
75
|
+
# "start_at"=>0,
|
76
|
+
# "end_at"=>0,
|
77
|
+
# "value_at"=>0,
|
78
|
+
# "redeem_at"=>0},
|
79
|
+
# {"platform"=>"Crypto.com",
|
80
|
+
# "identifier"=>"BAT",
|
81
|
+
# "supply_rate_percentage"=>"2.0",
|
82
|
+
# "borrow_rate_percentage"=>nil,
|
83
|
+
# "number_duration"=>nil,
|
84
|
+
# "length_duration"=>nil,
|
85
|
+
# "start_at"=>0,
|
86
|
+
# "end_at"=>0,
|
87
|
+
# "value_at"=>0,
|
88
|
+
# "redeem_at"=>0}
|
89
|
+
# ]
|
90
|
+
def finance_products(**options)
|
91
|
+
get 'finance_products', options
|
92
|
+
end
|
93
|
+
|
94
|
+
# @deprecated Use {#finance_products} instead
|
95
|
+
def get_finance_products(options: {})
|
96
|
+
finance_products(**options)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module CoingeckoRuby
|
2
|
+
class Client
|
3
|
+
module Indexes
|
4
|
+
# Fetches the list of market indexes listed in CoinGecko.
|
5
|
+
#
|
6
|
+
# @option options [Integer] :per_page (100) sets the number of results to return per page.
|
7
|
+
# @option options [Integer] :page sets the page for results.
|
8
|
+
#
|
9
|
+
# @return [Array<Hash>] each index's id, name, market name, last done, and whether it's a multiasset composite index.
|
10
|
+
#
|
11
|
+
# @example Get all market indexes.
|
12
|
+
# client.indexes
|
13
|
+
# @example Sample response object
|
14
|
+
# [
|
15
|
+
# {"name"=>"CoinFLEX (Futures) DFN",
|
16
|
+
# "id"=>"DFN",
|
17
|
+
# "market"=>"CoinFLEX (Futures)",
|
18
|
+
# "last"=>nil,
|
19
|
+
# "is_multi_asset_composite"=>nil},
|
20
|
+
# {"name"=>"Bibox (Futures) LINK",
|
21
|
+
# "id"=>"LINK",
|
22
|
+
# "market"=>"Bibox (Futures)",
|
23
|
+
# "last"=>nil,
|
24
|
+
# "is_multi_asset_composite"=>nil},
|
25
|
+
# {"name"=>"CME Bitcoin Futures BTC",
|
26
|
+
# "id"=>"BTC",
|
27
|
+
# "market"=>"CME Bitcoin Futures",
|
28
|
+
# "last"=>nil,
|
29
|
+
# "is_multi_asset_composite"=>false}
|
30
|
+
# ]
|
31
|
+
def indexes(**options)
|
32
|
+
get 'indexes', options
|
33
|
+
end
|
34
|
+
|
35
|
+
# @deprecated Use {#indexes} instead
|
36
|
+
def get_indexes(options: {})
|
37
|
+
indexes(**options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Fetches the ids of market indexes listed in CoinGecko.
|
41
|
+
#
|
42
|
+
# @return [Array<Hash>] each index's id and name.
|
43
|
+
#
|
44
|
+
# @example Get all market index ids and names.
|
45
|
+
# client.index_ids
|
46
|
+
# @example Sample response object
|
47
|
+
# [
|
48
|
+
# {"id"=>"LINK", "name"=>"Bibox (Futures) LINK"},
|
49
|
+
# {"id"=>"BTC", "name"=>"CME Bitcoin Futures BTC"},
|
50
|
+
# {"id"=>"XRP", "name"=>"Bibox (Futures) XRP"},
|
51
|
+
# {"id"=>"ETH", "name"=>"Crypto.com (Futures) ETH"}
|
52
|
+
# ]
|
53
|
+
def index_ids
|
54
|
+
get 'indexes/list'
|
55
|
+
end
|
56
|
+
|
57
|
+
# @deprecated Use {#index_ids} instead
|
58
|
+
def get_indexes_ids
|
59
|
+
index_ids
|
60
|
+
end
|
61
|
+
|
62
|
+
# Fetches the list of indexes based on the market and index given.
|
63
|
+
#
|
64
|
+
# @param market_id [String] filter results by the market id.
|
65
|
+
# @param coin_id [String] filter indexes from the given market by the index id.
|
66
|
+
#
|
67
|
+
# @return [Array<Hash>] the index's name, market, last done, and whether it's a multiasset composite index.
|
68
|
+
#
|
69
|
+
# @example Get all BTC indexes in the CME Futures market.
|
70
|
+
# client.indexes_by_market_and_coin(market_id: 'cme_futures', coin_id: 'btc')
|
71
|
+
# @example Sample response object
|
72
|
+
# {
|
73
|
+
# "name"=>"CME Bitcoin Futures BTC",
|
74
|
+
# "market"=>"CME Bitcoin Futures",
|
75
|
+
# "last"=>nil,
|
76
|
+
# "is_multi_asset_composite"=>false
|
77
|
+
# }
|
78
|
+
def indexes_by_market_and_coin(market_id, coin_id, **options)
|
79
|
+
get "indexes/#{market_id}/#{coin_id}", options
|
80
|
+
end
|
81
|
+
|
82
|
+
# @deprecated Use {#indexes_by_market_and_coin} instead
|
83
|
+
def get_indexes_by_market_and_index(market_id:, index_id:, options: {})
|
84
|
+
indexes_by_market_and_index(market_id, index_id, **options)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
module CoingeckoRuby
|
2
|
+
class Client
|
3
|
+
module Infos
|
4
|
+
# Fetches global crypto data from CoinGecko.
|
5
|
+
#
|
6
|
+
# @return [Hash] global crypto data (e.g. market cap, total volume, active ICOs, etc.)
|
7
|
+
#
|
8
|
+
# @example Get global crypto data.
|
9
|
+
# client.global_crypto_data
|
10
|
+
# @example Sample response object (truncated)
|
11
|
+
# {
|
12
|
+
# "data" => {
|
13
|
+
# "active_cryptocurrencies" => 7361,
|
14
|
+
# "upcoming_icos" => 0,
|
15
|
+
# "ongoing_icos" => 50,
|
16
|
+
# "ended_icos" => 3375,
|
17
|
+
# "markets" => 616,
|
18
|
+
# "total_market_cap" => {
|
19
|
+
# "btc" => 48541739.601360835,
|
20
|
+
# "eth" => 628896708.615425,
|
21
|
+
# "ltc" => 7052042789.61238,
|
22
|
+
# "bch" => 1934433566.5425043
|
23
|
+
# },
|
24
|
+
# "total_volume" => {
|
25
|
+
# "btc" => 6568919.505737251,
|
26
|
+
# "eth" => 85105558.43783577,
|
27
|
+
# "ltc" => 954318939.049309,
|
28
|
+
# "usd" => 286508058915.08606
|
29
|
+
# }
|
30
|
+
# "market_cap_percentage" => {
|
31
|
+
# "btc" => 38.55040456662042,
|
32
|
+
# "eth" => 18.387297257364622,
|
33
|
+
# },
|
34
|
+
# "market_cap_change_percentage_24h_usd" => -3.133283965790086,
|
35
|
+
# "updated_at" => 1621344957
|
36
|
+
# }
|
37
|
+
# }
|
38
|
+
def global_crypto_data
|
39
|
+
get 'global'
|
40
|
+
end
|
41
|
+
|
42
|
+
# @deprecated Use {#global_crypto_data} instead
|
43
|
+
def get_global_crypto_data
|
44
|
+
global_crypto_data
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fetches global crypto data from CoinGecko.
|
48
|
+
#
|
49
|
+
# @return [Hash] global defi data.
|
50
|
+
#
|
51
|
+
# @example Get global defi data.
|
52
|
+
# client.global_defi_data
|
53
|
+
# @example Sample response object
|
54
|
+
# {
|
55
|
+
# "data" => {
|
56
|
+
# "defi_market_cap" => "125745676087.2760332093360054945",
|
57
|
+
# "eth_market_cap" => "394420680555.8088822113739591981",
|
58
|
+
# "defi_to_eth_ratio" =>
|
59
|
+
# "31.8811062112863892278072770612100063079659263284319798945238447",
|
60
|
+
# "trading_volume_24h" => "15011166214.23270941006219308344",
|
61
|
+
# "defi_dominance" =>
|
62
|
+
# "5.8997291574682455351428477202615510371051549446051010984545824",
|
63
|
+
# "top_coin_name" => "Uniswap",
|
64
|
+
# "top_coin_defi_dominance" => 14.449398175884316
|
65
|
+
# }
|
66
|
+
# }
|
67
|
+
def global_defi_data
|
68
|
+
get 'global/decentralized_finance_defi'
|
69
|
+
end
|
70
|
+
|
71
|
+
# @deprecated Use {#global_defi_data} instead
|
72
|
+
def get_global_defi_data
|
73
|
+
global_defi_data
|
74
|
+
end
|
75
|
+
|
76
|
+
# Fetches the top 7 coin searches from CoinGecko in the last 24 hours.
|
77
|
+
#
|
78
|
+
# @return [Hash] the ternding searches and its information.
|
79
|
+
#
|
80
|
+
# @example Get trending searches in the last 24 hours.
|
81
|
+
# client.trending_searches
|
82
|
+
# @example Sample response object (truncated)
|
83
|
+
# {
|
84
|
+
# "coins" => [{
|
85
|
+
# "item" => {
|
86
|
+
# "id" => "shiba-inu",
|
87
|
+
# "coin_id" => 11939,
|
88
|
+
# "name" => "Shiba Inu",
|
89
|
+
# "symbol" => "SHIB",
|
90
|
+
# "market_cap_rank" => 24,
|
91
|
+
# "thumb" =>
|
92
|
+
# "https://assets.coingecko.com/coins/images/11939/thumb/SHIBLOGO.png?1600752116",
|
93
|
+
# "small" =>
|
94
|
+
# "https://assets.coingecko.com/coins/images/11939/small/SHIBLOGO.png?1600752116",
|
95
|
+
# "large" =>
|
96
|
+
# "https://assets.coingecko.com/coins/images/11939/large/SHIBLOGO.png?1600752116",
|
97
|
+
# "slug" => "shiba-inu",
|
98
|
+
# "price_btc" => 3.637711629799728e-10,
|
99
|
+
# "score" => 0
|
100
|
+
# }
|
101
|
+
# },
|
102
|
+
# ],
|
103
|
+
# "exchanges" => []
|
104
|
+
# }
|
105
|
+
def trending_searches
|
106
|
+
get 'search/trending'
|
107
|
+
end
|
108
|
+
|
109
|
+
# @deprecated Use {#trending_searches} instead
|
110
|
+
def get_trending_searches
|
111
|
+
trending_searches
|
112
|
+
end
|
113
|
+
|
114
|
+
# Fetches coin and/or market status updates.
|
115
|
+
#
|
116
|
+
# @option options [String] :category filter results by the given category. Valid values: general, milestone, partnership, exchange_listing, software_release, fund_movement, new_listings, event
|
117
|
+
# @option options [String] :project_type filter results by the project type. Fetches both coin and market status updates if left blank. Valid values: coin, market
|
118
|
+
# @option options [Integer] :per_page sets the number of results to return per page.
|
119
|
+
# @option options [Integer] :page sets the page for results.
|
120
|
+
#
|
121
|
+
# @return [Hash] the list of status updates and its information.
|
122
|
+
#
|
123
|
+
# @example Get a single status update.
|
124
|
+
# client.status_updates(per_page: 1)
|
125
|
+
# @example Sample response object
|
126
|
+
# {
|
127
|
+
# "status_updates" => [{
|
128
|
+
# "description" =>
|
129
|
+
# "📢 Community Call & AMA Invitation 📢\r\n" +
|
130
|
+
# "\r\n" +
|
131
|
+
# "Thursday 20th May at 4pm CET (Registration below)\r\n" +
|
132
|
+
# "\r\n" +
|
133
|
+
# "During this event, we will be updating our community on the latest news and developments at Fuse, covering:\r\n" +
|
134
|
+
# "\r\n" +
|
135
|
+
# "- Fuse Dollar (fUSD)\r\n" +
|
136
|
+
# "- Fuse Cash\r\n" +
|
137
|
+
# "- Latest partnerships and integrations.\r\n" +
|
138
|
+
# "- Binance Smart Chain (BSC) bridge.\r\n" +
|
139
|
+
# "- DeFi on Fuse.\r\n" +
|
140
|
+
# "- Featured communities.\r\n" +
|
141
|
+
# "- What to expect for the rest of Q2 and beyond!\r\n" +
|
142
|
+
# "\r\n" +
|
143
|
+
# "Please register 👉 https://bit.ly/3furWZs",
|
144
|
+
# "category" => "general",
|
145
|
+
# "created_at" => "2021-05-18T08:29:06.537Z",
|
146
|
+
# "user" => "Robert Miller",
|
147
|
+
# "user_title" => "Marcom Director ",
|
148
|
+
# "pin" => false,
|
149
|
+
# "project" => {
|
150
|
+
# "type" => "Coin",
|
151
|
+
# "id" => "fuse-network-token",
|
152
|
+
# "name" => "Fuse",
|
153
|
+
# "symbol" => "fuse",
|
154
|
+
# "image" => {
|
155
|
+
# "thumb" =>
|
156
|
+
# "https://assets.coingecko.com/coins/images/10347/thumb/vUXKHEe.png?1601523640",
|
157
|
+
# "small" =>
|
158
|
+
# "https://assets.coingecko.com/coins/images/10347/small/vUXKHEe.png?1601523640",
|
159
|
+
# "large" =>
|
160
|
+
# "https://assets.coingecko.com/coins/images/10347/large/vUXKHEe.png?1601523640"
|
161
|
+
# }
|
162
|
+
# }
|
163
|
+
# }]
|
164
|
+
# }
|
165
|
+
def status_updates(**options)
|
166
|
+
get 'status_updates', options
|
167
|
+
end
|
168
|
+
|
169
|
+
def get_status_updates(options: {})
|
170
|
+
status_updates(**options)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -2,8 +2,8 @@ module CoingeckoRuby
|
|
2
2
|
class Client
|
3
3
|
module Prices
|
4
4
|
# Fetches the current price for a coin in the given coin or currency.
|
5
|
-
# @param
|
6
|
-
# @param currency [String] the currency to display the coin's price.
|
5
|
+
# @param ids [String, Array] the coin id or array of ids to fetch.
|
6
|
+
# @param currency [String, Array] the currency or array of currencies to display the coin's price. Defaults to 'USD'
|
7
7
|
# @option options [Boolean] :include_market_cap include market cap data.
|
8
8
|
# @option options [Boolean] :include_24hr_vol include 24 hour volume data.
|
9
9
|
# @option options [Boolean] :include_24hr_change include 24 hour price change data.
|
@@ -12,16 +12,16 @@ module CoingeckoRuby
|
|
12
12
|
# @return [Hash] returns the given coin id and its current price.
|
13
13
|
#
|
14
14
|
# @example Fetch the current price in USD for Bitcoin.
|
15
|
-
# client.
|
16
|
-
# @example
|
15
|
+
# client.price('bitcoin', currency: 'usd')
|
16
|
+
# @example Sample response object
|
17
17
|
# {
|
18
18
|
# "bitcoin" => {
|
19
19
|
# "usd" => 47931 # current price in given currency
|
20
20
|
# }
|
21
21
|
# }
|
22
22
|
# @example Fetch the current price, market cap, 24 hour volume, 24 hour price change and last updated at for Bitcoin.
|
23
|
-
# client.
|
24
|
-
# @example
|
23
|
+
# client.price('bitcoin', 'usd', include_market_cap: true, include_24hr_vol: true, include_24hr_change: true, include_last_updated_at: true)
|
24
|
+
# @example Sample response object
|
25
25
|
# {
|
26
26
|
# "bitcoin" => {
|
27
27
|
# "usd" => 48217, # current price in given currency
|
@@ -31,44 +31,38 @@ module CoingeckoRuby
|
|
31
31
|
# "last_updated_at" => 1621142197 # last updated at UNIX timestamp for the given coin
|
32
32
|
# }
|
33
33
|
# }
|
34
|
+
def price(ids, currency: 'usd', **options)
|
35
|
+
ids = ids.join(',') if ids.is_a? Array
|
36
|
+
currency = currency.join(',') if currency.is_a? Array
|
37
|
+
get 'simple/price', { ids: ids, vs_currencies: currency, **options }
|
38
|
+
end
|
39
|
+
|
40
|
+
# @see Alias for {#price}
|
41
|
+
def prices(ids, currency: 'usd', **options)
|
42
|
+
price(ids, currency: currency, **options)
|
43
|
+
end
|
44
|
+
|
45
|
+
# @deprecated Use {#price} or {#prices} instead
|
34
46
|
def get_price(id:, currency: 'usd', options: {})
|
35
|
-
|
47
|
+
price(id, currency, **options)
|
36
48
|
end
|
37
49
|
|
38
50
|
# Fetches historical price data for a coin at a given date.
|
39
51
|
# @param id [String] the coin id to fetch.
|
40
|
-
# @param date [String] the date to fetch the historical price, date given must be in the form of 'DD-MM-YYYY' (e.g: '14-05-2021').
|
52
|
+
# @param date [String] the date to fetch the historical price, date given must be in the form of 'DD-MM-YYYY' (e.g: '14-05-2021'). Defaults to today's date.
|
41
53
|
#
|
42
54
|
# @return [Hash] returns the coin's historical price data on the given date.
|
43
55
|
#
|
44
56
|
# @example Fetch Bitcoin's price on 30th December, 2017.
|
45
|
-
# client.
|
46
|
-
# @example
|
57
|
+
# client.historical_price('bitcoin', date: '30-12-2017')
|
58
|
+
# @example Sample response object (truncated)
|
47
59
|
# {
|
48
60
|
# "id": "bitcoin",
|
49
61
|
# "symbol": "btc",
|
50
62
|
# "name": "Bitcoin",
|
51
63
|
# "localization": {
|
52
64
|
# "en": "Bitcoin",
|
53
|
-
# "de": "Bitcoin",
|
54
|
-
# "es": "Bitcoin",
|
55
|
-
# "fr": "Bitcoin",
|
56
|
-
# "it": "Bitcoin",
|
57
|
-
# "pl": "Bitcoin",
|
58
|
-
# "ro": "Bitcoin",
|
59
|
-
# "hu": "Bitcoin",
|
60
|
-
# "nl": "Bitcoin",
|
61
|
-
# "pt": "Bitcoin",
|
62
|
-
# "sv": "Bitcoin",
|
63
|
-
# "vi": "Bitcoin",
|
64
|
-
# "tr": "Bitcoin",
|
65
|
-
# "ru": "биткоин",
|
66
65
|
# "ja": "ビットコイン",
|
67
|
-
# "zh": "比特币",
|
68
|
-
# "zh-tw": "比特幣",
|
69
|
-
# "ko": "비트코인",
|
70
|
-
# "ar": "بيتكوين",
|
71
|
-
# "th": "บิตคอยน์",
|
72
66
|
# "id": "Bitcoin"
|
73
67
|
# },
|
74
68
|
# "image": {
|
@@ -77,175 +71,25 @@ module CoingeckoRuby
|
|
77
71
|
# },
|
78
72
|
# "market_data": {
|
79
73
|
# "current_price": {
|
80
|
-
# "aed": 50024.57906376443,
|
81
|
-
# "ars": 253468.12429692186,
|
82
|
-
# "aud": 17446.3215245937,
|
83
|
-
# "bch": 5.76928286478153,
|
84
|
-
# "bdt": 1126110.803183989,
|
85
|
-
# "bhd": 5132.860612995706,
|
86
|
-
# "bmd": 13620.3618741461,
|
87
|
-
# "brl": 45117.7211153463,
|
88
74
|
# "btc": 1,
|
89
|
-
# "cad": 17128.871750393,
|
90
|
-
# "chf": 13262.4868659029,
|
91
|
-
# "clp": 8362902.190725706,
|
92
|
-
# "cny": 88573.2132675718,
|
93
|
-
# "czk": 289914.5782287119,
|
94
|
-
# "dkk": 84525.1736167662,
|
95
75
|
# "eth": 18.483094024188404,
|
96
76
|
# "eur": 11345.8976447824,
|
97
77
|
# "gbp": 10079.0677868681,
|
98
|
-
# "hkd": 106417.930376984,
|
99
|
-
# "huf": 3526720.3000726495,
|
100
|
-
# "idr": 184652192.175199,
|
101
|
-
# "ils": 47387.96303252911,
|
102
|
-
# "inr": 869671.001953725,
|
103
|
-
# "jpy": 1535062.45448282,
|
104
|
-
# "krw": 14537693.2463698,
|
105
|
-
# "kwd": 4104.645874754543,
|
106
|
-
# "lkr": 2087919.548829924,
|
107
|
-
# "ltc": 60.96840666846534,
|
108
|
-
# "mmk": 18414729.253845528,
|
109
|
-
# "mxn": 267888.750532982,
|
110
|
-
# "myr": 55317.8739192755,
|
111
|
-
# "ngn": 4884546.501733771,
|
112
|
-
# "nok": 111755.75019546246,
|
113
|
-
# "nzd": 19178.1505368914,
|
114
|
-
# "php": 680527.760679833,
|
115
|
-
# "pkr": 1505414.7676248574,
|
116
|
-
# "pln": 47450.61669715,
|
117
|
-
# "rub": 785377.30638701,
|
118
|
-
# "sar": 51079.0811004227,
|
119
|
-
# "sek": 111446.704184538,
|
120
|
-
# "sgd": 18213.1478981081,
|
121
|
-
# "thb": 442954.59869004245,
|
122
|
-
# "try": 51700.07425935065,
|
123
|
-
# "twd": 404053.46952093,
|
124
|
-
# "uah": 382908.08925747185,
|
125
78
|
# "usd": 13620.3618741461,
|
126
|
-
# "vef": 140859.73944813784,
|
127
|
-
# "vnd": 309201434.91677517,
|
128
|
-
# "xag": 804.154745877564,
|
129
|
-
# "xau": 10.4549897745945,
|
130
|
-
# "xdr": 9563.95932114975,
|
131
|
-
# "zar": 168771.061713303,
|
132
|
-
# "bits": 1000000,
|
133
|
-
# "link": 22041.447552365687,
|
134
|
-
# "sats": 100000000
|
135
79
|
# },
|
136
80
|
# "market_cap": {
|
137
|
-
# "aed": 839030999274.6053,
|
138
|
-
# "ars": 4251262431254.5815,
|
139
|
-
# "aud": 292616246981.057,
|
140
|
-
# "bch": 96764575.68919012,
|
141
|
-
# "bdt": 18887552682553.043,
|
142
|
-
# "bhd": 86090263023.8938,
|
143
|
-
# "bmd": 228445816988.881,
|
144
|
-
# "brl": 756731337692.006,
|
145
81
|
# "btc": 16772375,
|
146
|
-
# "cad": 287291860324.498,
|
147
|
-
# "chf": 222443403147.498,
|
148
|
-
# "clp": 140265731631172.94,
|
149
|
-
# "cny": 1485583147878.69,
|
150
|
-
# "czk": 4862556024018.788,
|
151
|
-
# "dkk": 1417687908840.51,
|
152
82
|
# "eth": 310005384.13394696,
|
153
83
|
# "eur": 190297650009.907,
|
154
84
|
# "gbp": 169049904571.772,
|
155
|
-
# "hkd": 1784881435006.67,
|
156
|
-
# "huf": 59151475392930.96,
|
157
|
-
# "idr": 3097055811734500,
|
158
|
-
# "ils": 794808686467.7148,
|
159
|
-
# "inr": 14586448171393.6,
|
160
|
-
# "jpy": 25746643135006.3,
|
161
|
-
# "krw": 243831642763082,
|
162
|
-
# "kwd": 68844659853.58617,
|
163
|
-
# "lkr": 35019369642806.27,
|
164
|
-
# "ltc": 1022584979.7960014,
|
165
|
-
# "mmk": 308858744568967.1,
|
166
|
-
# "mxn": 4493130582220.62,
|
167
|
-
# "myr": 927812125576.808,
|
168
|
-
# "ngn": 81925445632016.88,
|
169
|
-
# "nok": 1874409350684.6182,
|
170
|
-
# "nzd": 321663132611.194,
|
171
|
-
# "php": 11414066800032.4,
|
172
|
-
# "pkr": 25249381013141.95,
|
173
|
-
# "pln": 795859537225.861,
|
174
|
-
# "rub": 13172642699212.8,
|
175
|
-
# "sar": 856717502871.7015,
|
176
|
-
# "sek": 1869225915097.14,
|
177
|
-
# "sgd": 305477746477.531,
|
178
|
-
# "thb": 7429400637203.895,
|
179
|
-
# "try": 867133033005.6757,
|
180
|
-
# "twd": 6776936310856.11,
|
181
|
-
# "uah": 6422278063559.784,
|
182
85
|
# "usd": 228445816988.881,
|
183
|
-
# "vef": 2362552372426.4595,
|
184
|
-
# "vnd": 5186042416962243,
|
185
|
-
# "xag": 13487584955.8882,
|
186
|
-
# "xau": 175355009.120664,
|
187
|
-
# "xdr": 160410312219.069,
|
188
|
-
# "zar": 2830691536203.66,
|
189
|
-
# "bits": 16772375000000,
|
190
|
-
# "link": 369687423891.10944,
|
191
|
-
# "sats": 1677237500000000
|
192
86
|
# },
|
193
87
|
# "total_volume": {
|
194
|
-
# "aed": 13223772038.888288,
|
195
|
-
# "ars": 67003156399.47071,
|
196
|
-
# "aud": 4611856472.88116,
|
197
|
-
# "bch": 1525083.9259334763,
|
198
|
-
# "bdt": 297682315984.16693,
|
199
|
-
# "bhd": 1356848571.721612,
|
200
|
-
# "bmd": 3600481281.03768,
|
201
|
-
# "brl": 11926666253.0629,
|
202
88
|
# "btc": 264345.493482963,
|
203
|
-
# "cad": 4527940055.66402,
|
204
|
-
# "chf": 3505878635.37842,
|
205
|
-
# "clp": 2210695506557.1357,
|
206
|
-
# "cny": 23413929770.588,
|
207
|
-
# "czk": 76637612249.77382,
|
208
|
-
# "dkk": 22343848731.4572,
|
209
89
|
# "eth": 4885922.610916088,
|
210
90
|
# "eur": 2999236911.91719,
|
211
91
|
# "gbp": 2664356147.96788,
|
212
|
-
# "hkd": 28131100320.9394,
|
213
|
-
# "huf": 932272618099.0865,
|
214
|
-
# "idr": 48811974863263.9,
|
215
|
-
# "ils": 12526794472.986298,
|
216
|
-
# "inr": 229893610179.28,
|
217
|
-
# "jpy": 405786842057.429,
|
218
|
-
# "krw": 3842973695315.56,
|
219
|
-
# "kwd": 1085044639.3347962,
|
220
|
-
# "lkr": 551932123488.1709,
|
221
|
-
# "ltc": 16116723.547645444,
|
222
|
-
# "mmk": 4867850691962.943,
|
223
|
-
# "mxn": 70815183958.1755,
|
224
|
-
# "myr": 14623030679.6192,
|
225
|
-
# "ngn": 1291207855441.2922,
|
226
|
-
# "nok": 29542128934.978218,
|
227
|
-
# "nzd": 5069657667.76511,
|
228
|
-
# "php": 179894446725.766,
|
229
|
-
# "pkr": 397949609644.3324,
|
230
|
-
# "pln": 12543356686.879,
|
231
|
-
# "rub": 207610951627.194,
|
232
|
-
# "sar": 13502524900.147509,
|
233
|
-
# "sek": 29460434014.7115,
|
234
|
-
# "sgd": 4814563569.00357,
|
235
|
-
# "thb": 117093051981.26692,
|
236
|
-
# "try": 13666681643.19386,
|
237
|
-
# "twd": 106809713794.014,
|
238
|
-
# "uah": 101220027813.38469,
|
239
92
|
# "usd": 3600481281.03768,
|
240
|
-
# "vef": 37235637336.29954,
|
241
|
-
# "vnd": 81736005898715.08,
|
242
|
-
# "xag": 212574683.135671,
|
243
|
-
# "xau": 2763729.43132451,
|
244
|
-
# "xdr": 2528189546.40031,
|
245
|
-
# "zar": 44613869594.2467,
|
246
|
-
# "bits": 264345493482.963,
|
247
|
-
# "link": 5826557330.308955,
|
248
|
-
# "sats": 26434549348296.3
|
249
93
|
# }
|
250
94
|
# },
|
251
95
|
# "community_data": {
|
@@ -275,20 +119,27 @@ module CoingeckoRuby
|
|
275
119
|
# "bing_matches": null
|
276
120
|
# }
|
277
121
|
# }
|
122
|
+
def historical_price(id, date:, **options)
|
123
|
+
date = Time.now.strftime('%d-%m-%Y') if date.nil?
|
124
|
+
|
125
|
+
get "coins/#{id}/history", { date: date, **options }
|
126
|
+
end
|
127
|
+
|
128
|
+
# @deprecated Use {#historical_price} instead
|
278
129
|
def get_historical_price_on_date(id:, date:)
|
279
|
-
|
130
|
+
historical_price(id, date: date)
|
280
131
|
end
|
281
132
|
|
282
133
|
# Fetches a coin's historical price data in 5 - 10 minutes ranges.
|
283
134
|
# @note Minutely historical data is only available within the last 24 hours.
|
284
135
|
# @param id [String] the coin id to fetch.
|
285
|
-
# @param currency [String] the currency used to display minutely historical price.
|
136
|
+
# @param currency [String] the currency used to display minutely historical price. Defaults to 'USD'
|
286
137
|
#
|
287
138
|
# @return [Hash] returns the coin's minutely historical price data within the last 24 hours.
|
288
139
|
#
|
289
140
|
# @example Fetch Bitcoin's minutely historical price within the last 24 hours.
|
290
|
-
# client.
|
291
|
-
# @example
|
141
|
+
# client.minutely_historical_price('bitcoin')
|
142
|
+
# @example Sample response object (truncated)
|
292
143
|
# {
|
293
144
|
# "prices" => [
|
294
145
|
# [1621057474114, 49364.605172521166], # [UNIX timestamp for minutely price data, coin price in given currency]
|
@@ -306,21 +157,26 @@ module CoingeckoRuby
|
|
306
157
|
# [1621058047104, 57046967935.326035],
|
307
158
|
# ]
|
308
159
|
# }
|
160
|
+
def minutely_historical_price(id, currency: 'usd', **options)
|
161
|
+
get "coins/#{id}/market_chart", { vs_currency: currency, days: 1, **options }
|
162
|
+
end
|
163
|
+
|
164
|
+
# @deprecated Use {#minutely_historical_price} instead
|
309
165
|
def get_minutely_historical_prices(id:, currency: 'usd')
|
310
|
-
|
166
|
+
minutely_historical_price(id, currency: currency)
|
311
167
|
end
|
312
168
|
|
313
169
|
# Fetches a coin's historical price data in 1 hour ranges.
|
314
170
|
# @note Hourly historical data is only available within the last 90 days.
|
315
171
|
# @param id [String] the coin id to fetch.
|
316
|
-
# @param
|
317
|
-
# @param
|
172
|
+
# @param currency [String] the currency used to display hourly historical price. Defaults to 'USD'
|
173
|
+
# @param days [Integer] the number of days to fetch hourly historical prices (min: 1 day, max: 90 days). Defaults to 7 days
|
318
174
|
#
|
319
175
|
# @return [Hash] returns the coin's hourly historical price data within the number of days given.
|
320
176
|
#
|
321
|
-
# @example Fetch Bitcoin's hourly historical price within the last 7 days.
|
322
|
-
# client.
|
323
|
-
# @example
|
177
|
+
# @example Fetch Bitcoin's hourly historical price in USD within the last 7 days.
|
178
|
+
# client.hourly_historical_price('bitcoin', days: 7)
|
179
|
+
# @example Sample response object (truncated)
|
324
180
|
# {
|
325
181
|
# "prices" => [
|
326
182
|
# [1620540153122, 58533.64354969528], # [UNIX timestamp for minutely price data, coin price in given currency]
|
@@ -336,21 +192,27 @@ module CoingeckoRuby
|
|
336
192
|
# [1620547381049, 72064327648.28767],
|
337
193
|
# ]
|
338
194
|
# }
|
339
|
-
def
|
340
|
-
return
|
195
|
+
def hourly_historical_price(id, currency: 'usd', days: 7, **options)
|
196
|
+
return daily_historical_price(id, currrency: currency, days: days) if days > 90
|
341
197
|
|
342
|
-
get "coins/#{id}/market_chart", { vs_currency: currency, days: days }
|
198
|
+
get "coins/#{id}/market_chart", { vs_currency: currency, days: days, **options }
|
199
|
+
end
|
200
|
+
|
201
|
+
# @deprecated Use {#hourly_historical_price} instead
|
202
|
+
def get_hourly_historical_prices(id:, days:, currency: 'usd')
|
203
|
+
hourly_historical_price(id, currency: currency, days: days)
|
343
204
|
end
|
344
205
|
|
345
206
|
# Fetches a coin's historical price data in daily ranges.
|
346
207
|
# @param id [String] the coin id to fetch.
|
347
|
-
# @param days [Integer] the number of days to fetch daily historical prices.
|
348
|
-
# @param currency [String] the currency used to display daily historical price.
|
208
|
+
# @param days [Integer] the number of days to fetch daily historical prices. Defaults to 7 days.
|
209
|
+
# @param currency [String] the currency used to display daily historical price. Defaults to USD.
|
349
210
|
#
|
350
211
|
# @return [Hash] returns the coin's daily historical price data within the number of days given.
|
351
212
|
#
|
352
213
|
# @example Fetch Bitcoin's daily historical price within the last 14 days.
|
353
|
-
# client.
|
214
|
+
# client.daily_historical_prices('bitcoin', days: 14)
|
215
|
+
# @example Sample response object (truncated)
|
354
216
|
# {
|
355
217
|
# "prices" => [
|
356
218
|
# [1620000000000, 56600.74528738432], # [UNIX timestamp for minutely price data, coin price in given currency]
|
@@ -366,37 +228,40 @@ module CoingeckoRuby
|
|
366
228
|
# [1620172800000, 71296763919.13268],
|
367
229
|
# ]
|
368
230
|
# }
|
231
|
+
def daily_historical_price(id, currency: 'usd', days: 7, **options)
|
232
|
+
get "coins/#{id}/market_chart", { vs_currency: currency, days: days, interval: 'daily', **options }
|
233
|
+
end
|
234
|
+
|
235
|
+
# @deprecated Use {#daily_historical_price} instead
|
369
236
|
def get_daily_historical_prices(id:, days:, currency: 'usd')
|
370
|
-
|
237
|
+
daily_historical_price(id, currency: currency, days: days)
|
371
238
|
end
|
372
239
|
|
373
240
|
# Fetches a coin's open, high, low, and close (OHLC) data within the number of days given.
|
374
241
|
# @param id [String] the coin id to fetch.
|
375
|
-
# @param days [Integer, String] the number of days to fetch daily historical prices. Valid values: 1/7/14/30/90/180/365/'max'
|
376
|
-
# @param currency [String] the currency to display OHLC data.
|
242
|
+
# @param days [Integer, String] the number of days to fetch daily historical prices. Valid values: 1/7/14/30/90/180/365/'max'. Defaults to 7 days.
|
243
|
+
# @param currency [String] the currency to display OHLC data. Defaults to 'USD'.
|
377
244
|
#
|
378
245
|
# @return [Array<Array<String, Float>>] returns the coin's OHLC data within the number of days given.
|
379
246
|
# If the number of days given is between 1-2 days, the OHLC data is returned in 30-minute intervals.
|
380
247
|
# If the number of days given is between 3-30 days, the OHLC data is returned in 4-hour intervals.
|
381
248
|
# If the number of days given is more than 30 days, the OHLC data is returned in 4-day intervals.
|
382
249
|
#
|
383
|
-
# @example Fetch Bitcoin's OHLC data
|
384
|
-
# client.
|
385
|
-
# @example
|
250
|
+
# @example Fetch Bitcoin's OHLC data within the last 7 days.
|
251
|
+
# client.ohlc('bitcoin', days: 7)
|
252
|
+
# @example Sample response object (truncated)
|
386
253
|
# [
|
387
254
|
# [1620547200000, 58384.27, 58384.27, 58384.27, 58384.27], # [UNIX timestamp for OHLC data, open, high, low, close]
|
388
255
|
# [1620561600000, 58022.03, 58214.96, 57943.18, 58048.35],
|
389
256
|
# [1620576000000, 57956.7, 57956.7, 56636.68, 57302.22],
|
390
|
-
# [1620590400000, 57396.24, 57618.74, 57396.24, 57535.26],
|
391
|
-
# [1620604800000, 57347.57, 58071.98, 57347.57, 58050.13],
|
392
|
-
# [1620619200000, 58213.93, 59005.01, 58213.93, 58909.0],
|
393
|
-
# [1620633600000, 59577.8, 59577.8, 58849.82, 58849.82],
|
394
|
-
# [1620648000000, 58495.02, 58495.02, 57878.12, 57878.12],
|
395
|
-
# [1620662400000, 58239.57, 58239.57, 57237.93, 57237.93],
|
396
|
-
# [1620676800000, 58114.79, 58114.79, 56850.29, 56850.29],
|
397
257
|
# ]
|
258
|
+
def ohlc(id, currency: 'usd', days: 7, **options)
|
259
|
+
get "coins/#{id}/ohlc", { vs_currency: currency, days: days, **options }
|
260
|
+
end
|
261
|
+
|
262
|
+
# @deprecated Use {#ohlc} instead
|
398
263
|
def get_ohlc(id:, days:, currency: 'usd')
|
399
|
-
|
264
|
+
ohlc(id, currency: currency, days: days)
|
400
265
|
end
|
401
266
|
|
402
267
|
# Fetches the list of currencies currently supported by CoinGecko's API.
|
@@ -405,83 +270,29 @@ module CoingeckoRuby
|
|
405
270
|
#
|
406
271
|
# @example Fetch supported currencies.
|
407
272
|
# client.supported_currencies
|
408
|
-
# @example
|
273
|
+
# @example Sample response object (truncated)
|
409
274
|
# [
|
410
275
|
# "btc",
|
411
276
|
# "eth",
|
412
|
-
# "ltc",
|
413
|
-
# "bch",
|
414
|
-
# "bnb",
|
415
|
-
# "eos",
|
416
|
-
# "xrp",
|
417
|
-
# "xlm",
|
418
|
-
# "link",
|
419
|
-
# "dot",
|
420
277
|
# "yfi",
|
421
278
|
# "usd",
|
422
|
-
# "aed",
|
423
|
-
# "ars",
|
424
279
|
# "aud",
|
425
|
-
# "bdt",
|
426
|
-
# "bhd",
|
427
|
-
# "bmd",
|
428
|
-
# "brl",
|
429
|
-
# "cad",
|
430
|
-
# "chf",
|
431
|
-
# "clp",
|
432
|
-
# "cny",
|
433
|
-
# "czk",
|
434
|
-
# "dkk",
|
435
280
|
# "eur",
|
436
281
|
# "gbp",
|
437
|
-
# "hkd",
|
438
|
-
# "huf",
|
439
|
-
# "idr",
|
440
|
-
# "ils",
|
441
|
-
# "inr",
|
442
|
-
# "jpy",
|
443
|
-
# "krw",
|
444
|
-
# "kwd",
|
445
|
-
# "lkr",
|
446
|
-
# "mmk",
|
447
|
-
# "mxn",
|
448
|
-
# "myr",
|
449
|
-
# "ngn",
|
450
|
-
# "nok",
|
451
|
-
# "nzd",
|
452
|
-
# "php",
|
453
|
-
# "pkr",
|
454
|
-
# "pln",
|
455
|
-
# "rub",
|
456
|
-
# "sar",
|
457
|
-
# "sek",
|
458
|
-
# "sgd",
|
459
|
-
# "thb",
|
460
|
-
# "try",
|
461
|
-
# "twd",
|
462
|
-
# "uah",
|
463
|
-
# "vef",
|
464
|
-
# "vnd",
|
465
|
-
# "zar",
|
466
|
-
# "xdr",
|
467
|
-
# "xag",
|
468
|
-
# "xau",
|
469
|
-
# "bits",
|
470
|
-
# "sats"
|
471
282
|
# ]
|
472
283
|
def supported_currencies
|
473
|
-
get
|
284
|
+
get 'simple/supported_vs_currencies'
|
474
285
|
end
|
475
286
|
|
476
287
|
# Fetches the exchange rate for a coin or currency in the given coin or currency.
|
477
288
|
# @param from [String] the coin id or currency to be converted.
|
478
|
-
# @param to [String] the coin id or currency to convert against.
|
289
|
+
# @param to [String] the coin id or currency to convert against. Defaults to 'USD'.
|
479
290
|
#
|
480
291
|
# @return [Hash] returns the coin's exchange rate against the given coin or currency.
|
481
292
|
#
|
482
293
|
# @example Fetch the exchange rate for BTC-USD.
|
483
|
-
# client.
|
484
|
-
# @example
|
294
|
+
# client.exchange_rate(from: 'bitcoin', to: 'usd')
|
295
|
+
# @example Sample response object
|
485
296
|
# {
|
486
297
|
# "bitcoin" => {
|
487
298
|
# "usd" => 47931 # current price in given currency
|
@@ -489,14 +300,19 @@ module CoingeckoRuby
|
|
489
300
|
# }
|
490
301
|
# @example Fetch the exchange rate for BTC-ETH.
|
491
302
|
# client.get_exchange_rate(from: 'bitcoin', to: 'eth')
|
492
|
-
# @example
|
303
|
+
# @example Sample response object
|
493
304
|
# {
|
494
305
|
# "bitcoin" => {
|
495
306
|
# "eth" => 12.71434 # current price in given currency
|
496
307
|
# }
|
497
308
|
# }
|
309
|
+
def exchange_rate(from:, to: 'usd')
|
310
|
+
price(from, currency: to)
|
311
|
+
end
|
312
|
+
|
313
|
+
# @deprecated Use {#exchange_rate} instead
|
498
314
|
def get_exchange_rate(from:, to: 'usd')
|
499
|
-
|
315
|
+
exchange_rate(from: from, to: to)
|
500
316
|
end
|
501
317
|
end
|
502
318
|
end
|