coinmarketcap_free 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +38 -25
- data/lib/coinmarketcap_free/base.rb +3 -1
- data/lib/coinmarketcap_free/coin.rb +67 -1
- data/lib/coinmarketcap_free/cryptocurrencies.rb +52 -36
- data/lib/coinmarketcap_free/version.rb +1 -1
- data/lib/coinmarketcap_free.rb +59 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f89d021dcc8f88f0730ed6c3a95de9fe66125138007e30f643e2637c3cc0829
|
4
|
+
data.tar.gz: 5402fc9c5ff6766a6ee126057de2e12d96519c9622325b3d939e978f5e8f5dcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47678471ba7e3a8362485be4f4781d0c0837c22b969e90f20bcb40bfe662080827742fe6790137102817b076f18bb3a45685ef6199ea829d5d2cb861960835e9
|
7
|
+
data.tar.gz: 3a46d496f02511b7b6536c8d4dda4b1cc4ca73ee485b39a8271ca5ce1436ff0404563633ab792028f5226c8226b3426074f8497a6fed249b66408f9a90fac586
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
13
13
|
$ gem install coinmarketcap_free
|
14
14
|
|
15
15
|
## Usage
|
16
|
-
You can use the
|
16
|
+
You can use the class ```CoinmarketcapFree::Cryptocurrencies``` or single method ```CoinmarketcapFree.coins``` like this.
|
17
17
|
|
18
18
|
``` Ruby
|
19
19
|
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
@@ -112,10 +112,10 @@ Result:
|
|
112
112
|
}
|
113
113
|
```
|
114
114
|
|
115
|
-
|
115
|
+
If you want to sort in ascending, just write parameter:
|
116
116
|
|
117
117
|
``` Ruby
|
118
|
-
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1,
|
118
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sortType:'asc')
|
119
119
|
```
|
120
120
|
or
|
121
121
|
``` Ruby
|
@@ -123,29 +123,42 @@ list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
|
123
123
|
list.sort_type = 'asc'
|
124
124
|
```
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
|
142
|
-
|
143
|
-
| ```
|
144
|
-
| ```
|
126
|
+
You can also adding sort by:
|
127
|
+
|
128
|
+
``` Ruby
|
129
|
+
list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc', sortBy: 'name')
|
130
|
+
```
|
131
|
+
|
132
|
+
Convert cryptocurrency to:
|
133
|
+
|
134
|
+
``` Ruby
|
135
|
+
list = CoinmarketcapFree.coins(limit: 100, start: 1, convert: 'USD,BTC,ETH')
|
136
|
+
```
|
137
|
+
|
138
|
+
|
139
|
+
Parameters for Cryptocurrencies:
|
140
|
+
|
141
|
+
| Name | Type | Description | Examples |
|
142
|
+
|:------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
|
143
|
+
| ```limit:``` | Integer. | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size. ||
|
144
|
+
| ```start:``` | Integer. | Optionally offset the start (1-based index) of the paginated list of items to return. ||
|
145
|
+
| ```sortBy:``` | String. | Default: ```market_cap```. (```rank```, ```name```, ```symbol```, ```date_added```, ```market_cap```, ```market_cap_strict```, ```price```, ```circulating_supply```, ```total_supply```, ```max_supply```, ```num_market_pairs```, ```volume_24h```, ```percent_change_1h```, ```percent_change_24h```, ```percent_change_7d```, ```market_cap_by_total_supply_strict```, ```volume_7d```, ```volume_30d```). What field to sort the list of cryptocurrencies by. ||
|
146
|
+
| ```sortType:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. ||
|
147
|
+
| ```convert:``` | String. | Default: ```USD,BTC,ETH``` . Select cryptocurrencies to exchange (```AUD```, ```BRL```, ```CAD```, ```CHF```, ```CLP```, ```CNY```, ```CZK```, ```DKK```, ```EUR```, ```GBP```, ```HKD```, ```HUF```, ```IDR```, ```ILS```, ```INR```, ```JPY```, ```KRW```, ```MXN```, ```MYR```, ```NOK```, ```NZD```, ```PHP```, ```PKR```, ```PLN```, ```RUB```, ```SEK```, ```SGD```, ```THB```, ```TRY```, ```TWD```, ```ZAR```). | ```USD``` or ```USD,BTC,ETH``` |
|
148
|
+
| ```cryptoType:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. ||
|
149
|
+
| ```tagType:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. ||
|
150
|
+
| ```audited:``` | Boolean. | Show audited (true) or not (false) ||
|
151
|
+
| ```aux:``` | String. | Optionally specify a comma-separated list of supplemental data fields to return. Pass ```ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap``` to include all auxiliary fields. | ```ath``` or ```ath, atl, high24h, low24h``` |
|
152
|
+
| ```tags:``` | string. | If you want to see cryptocurrencies that can be mined, just type ```mineable```. ||
|
153
|
+
| ```volume24hRange:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. | ```0~100000000000000000``` |
|
154
|
+
| ```percentChange24hRange:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. | ```0~100``` or ```-10~100``` |
|
155
|
+
| ```circulatingSupplyRange:``` | String. | Optionally specify a threshold circulating supply to filter results by. | ```0~100000000000000000``` |
|
156
|
+
| ```priceRange:``` | String. | Optionally specify a threshold USD price to filter results by. | ```0~100000000000000000``` |
|
157
|
+
| ```marketCapRange:``` | String. | Optionally specify a threshold market cap to filter results by. | ```0~100000000000000000``` |
|
145
158
|
|
146
159
|
### Returns an interval of historic market quotes:
|
147
160
|
|
148
|
-
You can use the
|
161
|
+
You can use the class ```CoinmarketcapFree::Coin``` or single method ```CoinmarketcapFree.coin_history``` like this.
|
149
162
|
|
150
163
|
``` Ruby
|
151
164
|
coin = CoinmarketcapFree::Coin.new(1, '1D')
|
@@ -156,7 +169,7 @@ coin.get_data
|
|
156
169
|
or
|
157
170
|
|
158
171
|
``` Ruby
|
159
|
-
coin = CoinmarketcapFree.
|
172
|
+
coin = CoinmarketcapFree.coin_history(1, '1D')
|
160
173
|
```
|
161
174
|
|
162
175
|
Result:
|
@@ -194,7 +207,7 @@ Result:
|
|
194
207
|
|
195
208
|
Parameters for Coin:
|
196
209
|
|
197
|
-
| Name | Type | Description |
|
210
|
+
| Name | Type | Description | Examples |
|
198
211
|
|:-----------------|:---------|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|
|
199
212
|
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
200
213
|
| ```range_time``` | String. | Range time. | ```1D```, ```7D```, ```1M```, ```3M```, ```1Y```, ```YTD```, ```ALL``` or custom range ```1668981600~1671659999``` |
|
@@ -6,6 +6,8 @@ module CoinmarketcapFree
|
|
6
6
|
class BASE
|
7
7
|
protected
|
8
8
|
|
9
|
+
# @param [URI] url
|
10
|
+
# @return [String]
|
9
11
|
def request_to_read_data(url)
|
10
12
|
response = Net::HTTP.get_response(url, Hash('Accept': '*/*'))
|
11
13
|
|
@@ -14,6 +16,7 @@ module CoinmarketcapFree
|
|
14
16
|
response.read_body
|
15
17
|
end
|
16
18
|
|
19
|
+
# @return [String]
|
17
20
|
def generate_uri_for_data
|
18
21
|
raise NotImplementedError
|
19
22
|
end
|
@@ -22,7 +25,6 @@ module CoinmarketcapFree
|
|
22
25
|
|
23
26
|
attr_reader :get_data
|
24
27
|
|
25
|
-
# Refresh to get data
|
26
28
|
# @return [false, true] true data update is good If false is bad request, wrong parameter values, or the API has been updated
|
27
29
|
def update
|
28
30
|
begin
|
@@ -6,7 +6,7 @@ require 'coinmarketcap_free/base'
|
|
6
6
|
module CoinmarketcapFree
|
7
7
|
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Result json:
|
10
10
|
#
|
11
11
|
# {
|
12
12
|
# "data": {
|
@@ -47,12 +47,78 @@ module CoinmarketcapFree
|
|
47
47
|
attr_accessor :id,
|
48
48
|
:range_time
|
49
49
|
|
50
|
+
# Returns the CoinmarketcapFree::Coin.
|
50
51
|
# @param id [Integer] Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
|
51
52
|
# @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
52
53
|
def initialize(id = 1, range_time = '1D')
|
53
54
|
@id = id
|
54
55
|
@range_time = range_time
|
55
56
|
end
|
57
|
+
class << self
|
58
|
+
@@coin = Coin.new()
|
59
|
+
|
60
|
+
# Returns an interval of historic for the day
|
61
|
+
#
|
62
|
+
# @param [Integer] id Cryptocurrency identifier
|
63
|
+
def history_day(id)
|
64
|
+
history(id, '1D')
|
65
|
+
end
|
66
|
+
# Returns an interval of historic for the seven days
|
67
|
+
#
|
68
|
+
# @param [Integer] id Cryptocurrency identifier
|
69
|
+
def history_seven_days(id)
|
70
|
+
history(id, '7D')
|
71
|
+
end
|
72
|
+
# Returns an interval of historic for the one month
|
73
|
+
#
|
74
|
+
# @param [Integer] id Cryptocurrency identifier
|
75
|
+
def history_one_month(id)
|
76
|
+
history(id, '1M')
|
77
|
+
end
|
78
|
+
# Returns an interval of historic for the three months
|
79
|
+
#
|
80
|
+
# @param [Integer] id Cryptocurrency identifier
|
81
|
+
def history_three_months(id)
|
82
|
+
history(id, '3M')
|
83
|
+
end
|
84
|
+
# Returns an interval of historic for the one year
|
85
|
+
#
|
86
|
+
# @param [Integer] id Cryptocurrency identifier
|
87
|
+
def history_one_year(id)
|
88
|
+
history(id, '1Y')
|
89
|
+
end
|
90
|
+
# Returns an interval of historic for the current year
|
91
|
+
#
|
92
|
+
# @param [Integer] id Cryptocurrency identifier
|
93
|
+
def history_current_year(id)
|
94
|
+
history(id, 'YTD')
|
95
|
+
end
|
96
|
+
# Returns an interval of historic for the current year
|
97
|
+
#
|
98
|
+
# @param [Integer] id Cryptocurrency identifier
|
99
|
+
def history_all(id)
|
100
|
+
history(id, 'ALL')
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
104
|
+
#
|
105
|
+
# Unix Epoch. (SECONDS SINCE JAN 01 1970 (UTC))
|
106
|
+
#
|
107
|
+
# CoinmarketcapFree::Coin.history_custom_time(1, 1675085165, 1675105165)
|
108
|
+
#
|
109
|
+
# @param [Integer] id Cryptocurrency identifier
|
110
|
+
# @param [Integer] from Enter a Timestamp
|
111
|
+
# @param [Integer] to Enter a Timestamp
|
112
|
+
def history_custom_time(id, from, to)
|
113
|
+
history(id, "#{from}~#{to}")
|
114
|
+
end
|
115
|
+
|
116
|
+
private def history(id, range_time)
|
117
|
+
@@coin.id = id
|
118
|
+
@@coin.range_time = range_time
|
119
|
+
@@coin.update ? @@coin.get_data : nil
|
120
|
+
end
|
121
|
+
end
|
56
122
|
|
57
123
|
private
|
58
124
|
def generate_uri_for_data
|
@@ -6,7 +6,11 @@ require 'coinmarketcap_free/base'
|
|
6
6
|
module CoinmarketcapFree
|
7
7
|
# Get a list of cryptocurrencies.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
10
|
+
# list.update
|
11
|
+
# list.get_data
|
12
|
+
#
|
13
|
+
# Result json:
|
10
14
|
#
|
11
15
|
# {
|
12
16
|
# "data": {
|
@@ -94,61 +98,73 @@ module CoinmarketcapFree
|
|
94
98
|
# 'cryptoCurrencyList' - Array of cryptocurrency objects matching the list options.
|
95
99
|
# 'totalCount' - Total number of cryptocurrencies
|
96
100
|
# 'status' - Standardized status object for API calls.
|
101
|
+
#
|
102
|
+
# If you want to sort in ascending, just write parameter:
|
103
|
+
#
|
104
|
+
# list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sortType:'asc')
|
105
|
+
#
|
106
|
+
# or
|
107
|
+
#
|
108
|
+
# list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
109
|
+
# list.sortType = 'asc'
|
110
|
+
#
|
111
|
+
# Also see other parameters.
|
97
112
|
class Cryptocurrencies < BASE
|
98
113
|
|
99
114
|
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'.freeze
|
100
115
|
private_constant :URL_API
|
101
116
|
|
102
|
-
#
|
117
|
+
# Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash. The primary options are:
|
103
118
|
#
|
104
|
-
# @param
|
105
|
-
# @
|
106
|
-
# @
|
107
|
-
# @
|
108
|
-
# @
|
109
|
-
# @
|
110
|
-
# @
|
111
|
-
# @
|
112
|
-
# @
|
113
|
-
# @
|
114
|
-
# @
|
115
|
-
# @
|
116
|
-
# @
|
117
|
-
# @
|
118
|
-
# @
|
119
|
-
|
119
|
+
# @param [Hash] options the parameters for creating a request to the server
|
120
|
+
# @option options [Integer] :start (1) Optionally offset the start (1-based index) of the paginated list of items to return.
|
121
|
+
# @option options [Integer] :limit (100) Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
|
122
|
+
# @option options [String] :sortBy ('market_cap') What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
|
123
|
+
# @option options [String] :sortType ('desc') The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
|
124
|
+
# @option options [String] :convert ('USD') Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
|
125
|
+
# @option options [String] :cryptoType ('all') The type of cryptocurrency to include. ('all', 'coins', 'tokens')
|
126
|
+
# @option options [String] :tagType ('all') The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
|
127
|
+
# @option options [false, true] :audited Show audited 'true' or not 'false'
|
128
|
+
# @option options [String] :aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
|
129
|
+
# @option options [String] :tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
130
|
+
# @option options [String] :volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
|
131
|
+
# @option options [String] :percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
|
132
|
+
# @option options [String] :circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
133
|
+
# @option options [String] :priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
134
|
+
# @option options [String] :marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
135
|
+
def initialize(options = {})
|
120
136
|
@limit = options[:limit].nil? ? 100 : options[:limit] # Integer
|
121
137
|
@start = options[:start].nil? ? 1 : options[:start] # Integer
|
122
|
-
@
|
123
|
-
@
|
138
|
+
@sortBy = options[:sortBy] # String
|
139
|
+
@sortType = options[:sortType] # String
|
124
140
|
@convert = options[:convert] # String
|
125
|
-
@
|
126
|
-
@
|
141
|
+
@cryptoType = options[:cryptoType] # String
|
142
|
+
@tagType = options[:tagType] # String
|
127
143
|
@audited = options[:audited] # Boolean
|
128
144
|
@aux = options[:aux] # String
|
129
145
|
@tags = options[:tags] # String
|
130
|
-
@
|
131
|
-
@
|
132
|
-
@
|
133
|
-
@
|
134
|
-
@
|
146
|
+
@volume24hRange = options[:volume24hRange] # String
|
147
|
+
@percentChange24hRange = options[:percentChange24hRange] # String
|
148
|
+
@circulatingSupplyRange = options[:circulatingSupplyRange] # String
|
149
|
+
@priceRange = options[:priceRange] # String
|
150
|
+
@marketCapRange = options[:marketCapRange] # String
|
135
151
|
end
|
136
152
|
|
137
153
|
attr_accessor :limit,
|
138
154
|
:start,
|
139
|
-
:
|
140
|
-
:
|
155
|
+
:sortBy,
|
156
|
+
:sortType,
|
141
157
|
:convert,
|
142
|
-
:
|
143
|
-
:
|
158
|
+
:cryptoType,
|
159
|
+
:tagType,
|
144
160
|
:audited,
|
145
161
|
:aux,
|
146
162
|
:tags,
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
163
|
+
:volume24hRange,
|
164
|
+
:percentChange24hRange,
|
165
|
+
:circulatingSupplyRange,
|
166
|
+
:priceRange,
|
167
|
+
:marketCapRange
|
152
168
|
|
153
169
|
private
|
154
170
|
def generate_uri_for_data
|
data/lib/coinmarketcap_free.rb
CHANGED
@@ -12,7 +12,9 @@ module CoinmarketcapFree
|
|
12
12
|
|
13
13
|
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
14
14
|
#
|
15
|
-
#
|
15
|
+
# history = CoinmarketcapFree.coins(1, '1D')
|
16
|
+
#
|
17
|
+
# Result json:
|
16
18
|
#
|
17
19
|
# {
|
18
20
|
# "data": {
|
@@ -58,7 +60,9 @@ module CoinmarketcapFree
|
|
58
60
|
|
59
61
|
# Get a list of cryptocurrencies
|
60
62
|
#
|
61
|
-
#
|
63
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1)
|
64
|
+
#
|
65
|
+
# Result json:
|
62
66
|
#
|
63
67
|
# {
|
64
68
|
# "data": {
|
@@ -147,24 +151,41 @@ module CoinmarketcapFree
|
|
147
151
|
# 'totalCount' - Total number of cryptocurrencies
|
148
152
|
# 'status' - Standardized status object for API calls.
|
149
153
|
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
# @param price_range [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
164
|
-
# @param market_cap_range [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
154
|
+
# If you want to sort in ascending, just write parameter:
|
155
|
+
#
|
156
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc')
|
157
|
+
#
|
158
|
+
# or
|
159
|
+
#
|
160
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'desc')
|
161
|
+
#
|
162
|
+
# You can also adding sort by:
|
163
|
+
#
|
164
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc', sortBy: 'name')
|
165
|
+
#
|
166
|
+
# Convert cryptocurrency to::
|
165
167
|
#
|
168
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1, convert: 'USD,BTC,ETH')
|
169
|
+
#
|
170
|
+
#
|
171
|
+
# @param [Hash] options the parameters for creating a request to the server
|
166
172
|
# @return [String, nil]
|
167
|
-
|
173
|
+
# @option options [Integer] :start (1) Optionally offset the start (1-based index) of the paginated list of items to return.
|
174
|
+
# @option options [Integer] :limit (100) Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
|
175
|
+
# @option options [String] :sortBy ('market_cap') What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
|
176
|
+
# @option options [String] :sortType ('desc') The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
|
177
|
+
# @option options [String] :convert ('USD') Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
|
178
|
+
# @option options [String] :cryptoType ('all') The type of cryptocurrency to include. ('all', 'coins', 'tokens')
|
179
|
+
# @option options [String] :tagType ('all') The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
|
180
|
+
# @option options [false, true] :audited Show audited 'true' or not 'false'
|
181
|
+
# @option options [String] :aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
|
182
|
+
# @option options [String] :tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
183
|
+
# @option options [String] :volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
|
184
|
+
# @option options [String] :percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
|
185
|
+
# @option options [String] :circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
186
|
+
# @option options [String] :priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
187
|
+
# @option options [String] :marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
188
|
+
def coins(options = {})
|
168
189
|
@@cryptocurrencies.instance_variables.each do |var_name|
|
169
190
|
value = options[var_name.to_s.delete('@').to_sym]
|
170
191
|
@@cryptocurrencies.instance_variable_set(var_name, value) unless value.nil?
|
@@ -172,5 +193,24 @@ module CoinmarketcapFree
|
|
172
193
|
|
173
194
|
@@cryptocurrencies.update ? @@cryptocurrencies.get_data : nil
|
174
195
|
end
|
196
|
+
|
197
|
+
# Get coin logo URL from coinmarketcap
|
198
|
+
#
|
199
|
+
# logo = CoinmarketcapFree.img_coin(1, 64)
|
200
|
+
#
|
201
|
+
# Result:
|
202
|
+
# "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
203
|
+
#
|
204
|
+
# @return [String] Return URL from coinmarketcap
|
205
|
+
# @param [Integer] id_coin Identify coin. For example, bitcoin has 1
|
206
|
+
# @param [Integer] size Choose one size: 64, 128, 200
|
207
|
+
def img_coin_url(id_coin, size)
|
208
|
+
size_x_size = case size
|
209
|
+
when 64, 128, 200
|
210
|
+
"#{size}x#{size}"
|
211
|
+
else raise ArgumentError
|
212
|
+
end
|
213
|
+
"https://s2.coinmarketcap.com/static/img/coins/#{size_x_size}/#{id_coin}.png"
|
214
|
+
end
|
175
215
|
end
|
176
|
-
end
|
216
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinmarketcap_free
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cosmic-1
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cryptocurrency information from the Coinmarketcap site without a key.
|
14
14
|
email:
|
@@ -32,7 +32,7 @@ files:
|
|
32
32
|
- lib/coinmarketcap_free/cryptocurrencies.rb
|
33
33
|
- lib/coinmarketcap_free/helper.rb
|
34
34
|
- lib/coinmarketcap_free/version.rb
|
35
|
-
homepage:
|
35
|
+
homepage:
|
36
36
|
licenses:
|
37
37
|
- MIT
|
38
38
|
metadata:
|