coingecko_client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8201a549684d13164e7be2d24e3b7cd1705a9629a4f667be2a700041ee7cf1c4
4
- data.tar.gz: ef4e06fa6e44789534f9e4b4063719ef9b5b2db92fe70ac5bfa9a79cc8a50534
3
+ metadata.gz: 3af7d5936d0df61051e26280ae616a949ceb0b84b386cc1737e9629a7bed6726
4
+ data.tar.gz: c914578222edc879982ddc343cbdff081d0f3874e560e36de2514ec91356fb1f
5
5
  SHA512:
6
- metadata.gz: 57bd9f719a5dfc883a4106cec1325c6bd56ff92dc268abbf64467b1f7f1958bb831da5691c8ad549f5803745878a87264991be1eadaa99dbf82299d1fed439de
7
- data.tar.gz: 31b50034e6ff4b7b9f02d7eef2d8f35da2518e185a660187f9b345b477c089858f177b505657cfb9e9de6c87c73971572426a5c84661cd2f2635cf02a8f3c372
6
+ metadata.gz: 97f15da83fb56076b2c3d9b06a155ca6ed11d89fd8e5dbc424abaf6da5b29c942012440009616db959f14f95090aac67a156f46a9d3ea245a23ef6c0a1194b1b
7
+ data.tar.gz: 117c31e94c4cc9ffa862e0d94df2d9dac00e15c766969816c3da6da883f8076a271cfcbbf0b45018496063764d19e06179161ea010b32b5acb75995df364e845
data/.gitignore CHANGED
@@ -10,4 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
- coingecko_client-0.1.0.gem
13
+ coingecko_client-0.1.*.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coingecko_client (0.1.0)
4
+ coingecko_client (0.1.1)
5
5
  excon (~> 0.75.0)
6
6
  json (~> 2.3)
7
7
 
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # CoingeckoClient
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/coingecko_client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is my first gem and the idea was to develop a super simple and lightweight client to connect with Coingecko API.
4
+ Keep in mind that this is by no means the oficial gem from Coingecko, it is a pet project that I have interest in keeping it working!
5
+ I published it with the methods that I need for another project, but I'll keep on adding more methods to interact with the rest of the API. Any comments, sugestions, Pull Requests, feel free to contact me.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,84 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ The available methods are:
26
+
27
+
28
+ * Check if API is up:
29
+ ```
30
+ 2.7.0 :026 > CoingeckoClient::Client.ping
31
+ => {"gecko_says"=>"(V3) To the Moon!"}
32
+ ```
33
+
34
+ * List coins
35
+
36
+ List all supported coins id, name and symbol (no pagination required)
37
+
38
+ ```
39
+ 2.7.0 :027 > list=CoingeckoClient::Client.coins_list
40
+ 2.7.0 :028 > list.count
41
+ => 7631
42
+ 2.7.0 :029 > list.first
43
+ => {"id"=>"01coin", "symbol"=>"zoc", "name"=>"01coin"}
44
+ ```
45
+ * Supported_vs_currencies<br>
46
+
47
+ Get list of supported_vs_currencies.
48
+ ```
49
+ 2.7.0 :002 > list = CoingeckoClient::Client.supported_vs_currencies
50
+ 2.7.0 :003 > list.count
51
+ => 55
52
+ 2.7.0 :004 > list.first
53
+ => "btc"
54
+ ```
55
+
56
+ * Current price <br>
57
+ Get the current price of any cryptocurrencies in any other supported currencies that you need.
58
+ ```
59
+ CoingeckoClient::Client.price(<coin>,<currency>)
60
+ ```
61
+ For example:
62
+ ```
63
+ 2.7.0 :016 > CoingeckoClient::Client.price('bitcoin','usd')
64
+ => 9246.4
65
+ ```
66
+
67
+ * Historical market data
68
+ To get the historical market data(price, market cap and trade volume) of a given coin, you would use:<br>
69
+ <sub><strong>
70
+ Coingecko's note about this API call: Minutely data will be used for duration within 1 day, Hourly data will be used for duration between 1 day and 90 days, Daily data will be used for duration above 90 days.
71
+ </sub></strong>
72
+
73
+ ```
74
+ CoingeckoClient::Client.coin_history(<coin>,<currency>,<number_of_days>)
75
+ ```
76
+ For example:
77
+ ```
78
+ CoingeckoClient::Client.coin_history('bitcoin','usd','7')
79
+ => {"prices"=>[[1593511281310, 9161.947854845832], ..., [1594113061000, 9247.986673179646]], market_caps"=>[[1593511281310, 168752424140.90503], ..., [...,...]], , "total_volumes"=>[[...]]}
80
+ ```
81
+
82
+ * Market data from coins: <br>
83
+ Use this to obtain all the coins market data (price, market cap, volume)
84
+
85
+ ```
86
+ 2.7.0 :019 > CoingeckoClient::Client.coins_market(currency: 'usd',ids_list:['maker'], price_change_percentage:'7d' )
87
+ => [{"id"=>"maker", "symbol"=>"mkr", "name"=>"Maker", "image"=>"https://assets.coingecko.com/coins/images/1364/large/Mark_Maker.png?1585191826", "current_price"=>465.65, "market_cap"=>419598650, "market_cap_rank"=>30, "total_volume"=>11790566, "high_24h"=>487.76, "low_24h"=>464.65, "price_change_24h"=>-3.61639711, "price_change_percentage_24h"=>-0.77064, "market_cap_change_24h"=>-3408068.16243178, "market_cap_change_percentage_24h"=>-0.80568, "circulating_supply"=>902019.8121058022, "total_supply"=>1005576.0, "ath"=>1798.7, "ath_change_percentage"=>-74.14012, "ath_date"=>"2018-01-20T00:00:00.000Z", "atl"=>168.36, "atl_change_percentage"=>176.28269, "atl_date"=>"2020-03-16T20:52:36.527Z", "roi"=>nil, "last_updated"=>"2020-07-07T09:33:19.687Z", "price_change_percentage_7d_in_currency"=>2.802621306390991}]
88
+ ```
89
+
90
+ * List exchanges <br>
91
+ List all exchanges <br>
92
+ <sub>Default value:: 100</sub>
93
+ ```
94
+ 2.7.0 :030 > list=CoingeckoClient::Client.list_exchanges
95
+ 2.7.0 :031 > list.count
96
+ => 100
97
+ 2.7.0 :032 > list.first
98
+ => {"id"=>"binance", "name"=>"Binance", "year_established"=>2017, "country"=>"Cayman Islands", "description"=>"", "url"=>"https://www.binance.com/", "image"
99
+ =>"https://assets.coingecko.com/markets/images/52/small/binance.jpg?1519353250", "has_trading_incentive"=>false, "trust_score"=>10, "trust_score_rank"=>1, "t
100
+ rade_volume_24h_btc"=>202207.8584274921, "trade_volume_24h_btc_normalized"=>202207.8584274921}
101
+ ```
102
+
26
103
 
27
104
  ## Development
28
105
 
@@ -8,7 +8,9 @@ Gem::Specification.new do |spec|
8
8
 
9
9
 
10
10
  spec.summary = 'A simple coingecko API client '
11
- spec.description = 'Simple client for the coingecko API. This is a work in progress and not all API calls are available at this time.'
11
+ spec.description = 'This is my first gem and the idea was to develop a super simple and lightweight client to connect with Coingecko API.
12
+ Keep in mind that this is by no means an oficial gem from Coingecko, it is a MIT license pet project! Use at your own discretion!
13
+ I published it originally with the methods that I needed for another project, but I\'ll keep on adding more methods to interact with the rest of the API. Any comments, sugestions, Pull Requests, feel free to contact me.'
12
14
  spec.homepage = 'https://github.com/Bruck1701/coingecko_client'
13
15
  spec.license = "MIT"
14
16
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
@@ -1,19 +1,21 @@
1
- require "coingecko_client/version"
1
+ require 'coingecko_client/version'
2
2
  require 'excon'
3
3
  require 'json'
4
4
 
5
5
  module CoingeckoClient
6
6
  class Error < StandardError; end
7
-
7
+
8
8
  # This is a simple client to connect to Coingecko
9
9
  class Client
10
10
 
11
11
  def self.ping
12
+ # Check API server status
12
13
  api_call('ping')
13
14
  end
14
-
15
15
 
16
+ ######### simple API calls #############
16
17
  def self.price(coin, currency)
18
+ # Get the current price of any cryptocurrencies in any other supported currencies that you need.
17
19
  coin = coin.downcase
18
20
  currency = currency.downcase
19
21
  result = api_call("simple/price?ids=#{coin}&vs_currencies=#{currency}")
@@ -22,16 +24,38 @@ module CoingeckoClient
22
24
  result[coin][currency]
23
25
  end
24
26
 
25
-
26
27
  def self.token_price(platform_id='ethereum',address,currency)
27
28
  api_call("simple/token_price/#{platform_id}?contract_addresses=#{address}&vs_currencies=#{currency}")
28
29
  end
29
30
 
31
+ def self.supported_vs_currencies
32
+ api_call('simple/supported_vs_currencies')
33
+ end
30
34
 
35
+ ############### coins API calls ################
31
36
  def self.list_coins
32
- api_call('coins/list')
37
+ api_call('coins/list')
38
+ end
39
+
40
+ def self.coins_list
41
+ list_coins
33
42
  end
34
43
 
44
+ def self.coins_market(currency: 'usd',
45
+ ids_list: ['bitcoin'],
46
+ order: 'market_cap_desc',
47
+ per_page: 100,
48
+ page: 1,
49
+ sparkline: false,
50
+ price_change_percentage: '')
51
+
52
+ ids = ids_list.join('%2C')
53
+ request = "coins/markets?vs_currency=#{currency}&ids=#{ids}"
54
+ request += "&order=#{order}&per_page=#{per_page}&page=#{page}&sparkline=#{sparkline}"
55
+ request += "&price_change_percentage=#{price_change_percentage}" unless price_change_percentage.empty?
56
+
57
+ api_call(request)
58
+ end
35
59
 
36
60
  def self.coin_history(coin,currency,days)
37
61
  api_call("coins/#{coin.downcase}/market_chart?vs_currency=#{currency.downcase}&days=#{days}")
@@ -46,7 +70,6 @@ module CoingeckoClient
46
70
  end
47
71
  end
48
72
 
49
-
50
73
  private_class_method def self.api_call(api_request)
51
74
  endpoint_head = 'https://api.coingecko.com/api/v3/'
52
75
  url = endpoint_head + api_request
@@ -1,3 +1,3 @@
1
1
  module CoingeckoClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coingecko_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruck1701
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -38,8 +38,12 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
- description: Simple client for the coingecko API. This is a work in progress and not
42
- all API calls are available at this time.
41
+ description: "This is my first gem and the idea was to develop a super simple and
42
+ lightweight client to connect with Coingecko API. \n Keep in mind that this is
43
+ by no means an oficial gem from Coingecko, it is a MIT license pet project! Use
44
+ at your own discretion!\n I published it originally with the methods that I needed
45
+ for another project, but I'll keep on adding more methods to interact with the rest
46
+ of the API. Any comments, sugestions, Pull Requests, feel free to contact me."
43
47
  email:
44
48
  - kummel@gmail.com
45
49
  executables: []