Class: Coingecko::API
- Inherits:
-
Object
- Object
- Coingecko::API
- Defined in:
- lib/coingecko/api.rb
Class Method Summary collapse
- .api_call(endpoint = "coins") ⇒ Object
- .get_all_coins ⇒ Object
- .get_global_info ⇒ Object
- .list_top_100(currency = "usd") ⇒ Object
- .look_up_coin(coin_id) ⇒ Object
- .supported_base ⇒ Object
Class Method Details
.api_call(endpoint = "coins") ⇒ Object
3 4 5 6 7 8 |
# File 'lib/coingecko/api.rb', line 3 def self.api_call(endpoint="coins") #defaults to list coins if no argument passed res = open("https://api.coingecko.com/api/v3/#{endpoint}").read @json = JSON.parse(res) @json end |
.get_all_coins ⇒ Object
20 21 22 |
# File 'lib/coingecko/api.rb', line 20 def self.get_all_coins self.api_call("coins/list") end |
.get_global_info ⇒ Object
28 29 30 |
# File 'lib/coingecko/api.rb', line 28 def self.get_global_info self.api_call("global") end |
.list_top_100(currency = "usd") ⇒ Object
11 12 13 |
# File 'lib/coingecko/api.rb', line 11 def self.list_top_100(currency="usd") self.api_call("coins/markets?vs_currency=#{currency}") end |
.look_up_coin(coin_id) ⇒ Object
24 25 26 |
# File 'lib/coingecko/api.rb', line 24 def self.look_up_coin(coin_id) self.api_call("coins/#{coin_id}?tickers=true&market_data=true&community_data=true&developer_data=true&sparkline=true") end |
.supported_base ⇒ Object
15 16 17 |
# File 'lib/coingecko/api.rb', line 15 def self.supported_base self.api_call("simple/supported_vs_currencies") end |