coinmarketcap_free 0.1.0 → 0.1.2
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/.idea/coinmarketcap_free.iml +1 -29
- data/Gemfile.lock +1 -1
- data/README.md +43 -25
- data/lib/coinmarketcap_free/base.rb +6 -2
- data/lib/coinmarketcap_free/coin.rb +9 -8
- data/lib/coinmarketcap_free/cryptocurrencies.rb +54 -27
- data/lib/coinmarketcap_free/version.rb +1 -1
- data/lib/coinmarketcap_free.rb +199 -0
- metadata +2 -3
- data/sig/coinmarketcap_free.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d2f0b9d06cb2aa30965c8c67c23fe6694628466364a16b0cdad46ccf96dbd39
|
4
|
+
data.tar.gz: caef79e1398c48c30e246ca336388ba5986f5f5ad0391f33e0825f48547f8bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ac065298e6cbe7daf6c57f64afb9eae284b1589447260f1a166854f5e7ce1201c2f514c9fa645c9095de3b7890223593d38c1a971a10fc601f82d2aacf6511
|
7
|
+
data.tar.gz: 677eb71065cd99bc1d7cc9524e4f785684522272c98ab2c52f2de09b9e40b47e671f7af02dcee902b342a9ad77b5fb3842268476bd512a0fb44235fe2afd8539
|
@@ -21,35 +21,7 @@
|
|
21
21
|
</component>
|
22
22
|
<component name="RakeTasksCache">
|
23
23
|
<option name="myRootTask">
|
24
|
-
<RakeTaskImpl id="rake"
|
25
|
-
<subtasks>
|
26
|
-
<RakeTaskImpl description="Build coinmarketcap_free-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
27
|
-
<RakeTaskImpl id="build">
|
28
|
-
<subtasks>
|
29
|
-
<RakeTaskImpl description="Generate SHA512 checksum if coinmarketcap_free-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
30
|
-
</subtasks>
|
31
|
-
</RakeTaskImpl>
|
32
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
33
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
34
|
-
<RakeTaskImpl description="Build and install coinmarketcap_free-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
35
|
-
<RakeTaskImpl id="install">
|
36
|
-
<subtasks>
|
37
|
-
<RakeTaskImpl description="Build and install coinmarketcap_free-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
38
|
-
</subtasks>
|
39
|
-
</RakeTaskImpl>
|
40
|
-
<RakeTaskImpl description="Create tag v0.1.0 and build and push coinmarketcap_free-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
41
|
-
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
42
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
43
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
44
|
-
<RakeTaskImpl id="release">
|
45
|
-
<subtasks>
|
46
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
47
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
48
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
49
|
-
</subtasks>
|
50
|
-
</RakeTaskImpl>
|
51
|
-
</subtasks>
|
52
|
-
</RakeTaskImpl>
|
24
|
+
<RakeTaskImpl id="rake" />
|
53
25
|
</option>
|
54
26
|
</component>
|
55
27
|
</module>
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,10 +13,18 @@ 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 class ```CoinmarketcapFree::Cryptocurrencies``` or single method ```CoinmarketcapFree.coins``` like this.
|
17
|
+
|
16
18
|
``` Ruby
|
17
|
-
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1)
|
19
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
18
20
|
list.update
|
19
|
-
list.
|
21
|
+
list.get_data
|
22
|
+
```
|
23
|
+
|
24
|
+
or
|
25
|
+
|
26
|
+
``` Ruby
|
27
|
+
list = CoinmarketcapFree.coins(limit: 100, start: 1)
|
20
28
|
```
|
21
29
|
|
22
30
|
Result:
|
@@ -104,41 +112,51 @@ Result:
|
|
104
112
|
}
|
105
113
|
```
|
106
114
|
|
107
|
-
|
115
|
+
If you want to sort in ascending, just write parameter:
|
108
116
|
|
109
117
|
``` Ruby
|
110
|
-
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1, sort_type:'asc')
|
118
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sort_type:'asc')
|
111
119
|
```
|
112
120
|
or
|
113
121
|
``` Ruby
|
114
|
-
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1)
|
122
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
115
123
|
list.sort_type = 'asc'
|
116
124
|
```
|
117
125
|
|
118
126
|
Also other parameters for Cryptocurrencies:
|
119
127
|
|
120
|
-
| Name | Type | Description
|
121
|
-
|
122
|
-
| ```
|
123
|
-
| ```
|
124
|
-
| ```
|
125
|
-
| ```
|
126
|
-
| ```
|
127
|
-
| ```
|
128
|
-
| ```
|
129
|
-
| ```
|
130
|
-
| ```
|
131
|
-
| ```
|
132
|
-
| ```
|
133
|
-
| ```
|
134
|
-
| ```
|
128
|
+
| Name | Type | Description | Examples |
|
129
|
+
|:--------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
|
130
|
+
| ```limit:``` | Integer. | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size. ||
|
131
|
+
| ```start:``` | Integer. | Optionally offset the start (1-based index) of the paginated list of items to return. ||
|
132
|
+
| ```sort_by:``` | 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. ||
|
133
|
+
| ```sort_type:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. ||
|
134
|
+
| ```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``` |
|
135
|
+
| ```crypto_type:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. ||
|
136
|
+
| ```tag_type:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. ||
|
137
|
+
| ```audited:``` | Boolean. | Show audited (true) or not (false) ||
|
138
|
+
| ```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``` |
|
139
|
+
| ```tags:``` | string. | If you want to see cryptocurrencies that can be mined, just type ```mineable```. ||
|
140
|
+
| ```volume_24h_range:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. | ```0~100000000000000000``` |
|
141
|
+
| ```percent_change_24h_range:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. | ```0~100``` or ```-10~100``` |
|
142
|
+
| ```circulating_supply_range:``` | String. | Optionally specify a threshold circulating supply to filter results by. | ```0~100000000000000000``` |
|
143
|
+
| ```price_range:``` | String. | Optionally specify a threshold USD price to filter results by. | ```0~100000000000000000``` |
|
144
|
+
| ```market_cap_range:``` | String. | Optionally specify a threshold market cap to filter results by. | ```0~100000000000000000``` |
|
135
145
|
|
136
146
|
### Returns an interval of historic market quotes:
|
137
147
|
|
148
|
+
You can use the class ```CoinmarketcapFree::Coin``` or single method ```CoinmarketcapFree.coin_history``` like this.
|
149
|
+
|
138
150
|
``` Ruby
|
139
151
|
coin = CoinmarketcapFree::Coin.new(1, '1D')
|
140
152
|
coin.update
|
141
|
-
coin.
|
153
|
+
coin.get_data
|
154
|
+
```
|
155
|
+
|
156
|
+
or
|
157
|
+
|
158
|
+
``` Ruby
|
159
|
+
coin = CoinmarketcapFree.coin_history(1, '1D')
|
142
160
|
```
|
143
161
|
|
144
162
|
Result:
|
@@ -176,10 +194,10 @@ Result:
|
|
176
194
|
|
177
195
|
Parameters for Coin:
|
178
196
|
|
179
|
-
| Name | Type | Description
|
180
|
-
|
181
|
-
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap.
|
182
|
-
| ```range_time``` | String. | Range time.
|
197
|
+
| Name | Type | Description | Examples |
|
198
|
+
|:-----------------|:---------|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|
|
199
|
+
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
200
|
+
| ```range_time``` | String. | Range time. | ```1D```, ```7D```, ```1M```, ```3M```, ```1Y```, ```YTD```, ```ALL``` or custom range ```1668981600~1671659999``` |
|
183
201
|
|
184
202
|
## Development
|
185
203
|
|
@@ -20,15 +20,19 @@ module CoinmarketcapFree
|
|
20
20
|
|
21
21
|
public
|
22
22
|
|
23
|
-
attr_reader :
|
23
|
+
attr_reader :get_data
|
24
24
|
|
25
|
+
# Refresh to get data
|
26
|
+
# @return [false, true] true data update is good If false is bad request, wrong parameter values, or the API has been updated
|
25
27
|
def update
|
26
28
|
begin
|
27
29
|
url = generate_uri_for_data
|
28
|
-
|
30
|
+
data = request_to_read_data(url)
|
29
31
|
rescue
|
32
|
+
@get_data = nil
|
30
33
|
false
|
31
34
|
else
|
35
|
+
@get_data = data
|
32
36
|
true
|
33
37
|
end
|
34
38
|
end
|
@@ -6,9 +6,9 @@ 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": {
|
13
13
|
# "points": {
|
14
14
|
# "1673192010": {
|
@@ -35,10 +35,10 @@ module CoinmarketcapFree
|
|
35
35
|
# "elapsed": "2",
|
36
36
|
# "credit_count": 0
|
37
37
|
# }
|
38
|
-
#
|
38
|
+
# }
|
39
39
|
#
|
40
40
|
# 'data' - Results of your query returned as an object map.
|
41
|
-
#
|
41
|
+
# 'points' - Price range history
|
42
42
|
# 'status' - Standardized status object for API calls.
|
43
43
|
class Coin < BASE
|
44
44
|
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/chart'.freeze
|
@@ -46,14 +46,15 @@ module CoinmarketcapFree
|
|
46
46
|
|
47
47
|
attr_accessor :id,
|
48
48
|
:range_time
|
49
|
-
|
50
|
-
# id Integer
|
51
|
-
# range_time String
|
52
|
-
def initialize(id, range_time)
|
49
|
+
# Returns the CoinmarketcapFree::Coin.
|
50
|
+
# @param id [Integer] Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
|
51
|
+
# @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
52
|
+
def initialize(id = 1, range_time = '1D')
|
53
53
|
@id = id
|
54
54
|
@range_time = range_time
|
55
55
|
end
|
56
56
|
|
57
|
+
private
|
57
58
|
def generate_uri_for_data
|
58
59
|
query = "#{URL_API}?id=#{id}&range=#{range_time}"
|
59
60
|
URI(query)
|
@@ -4,11 +4,15 @@ require 'coinmarketcap_free/helper'
|
|
4
4
|
require 'coinmarketcap_free/base'
|
5
5
|
|
6
6
|
module CoinmarketcapFree
|
7
|
-
# Get a list of cryptocurrencies
|
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
|
10
12
|
#
|
11
|
-
#
|
13
|
+
# Result json:
|
14
|
+
#
|
15
|
+
# {
|
12
16
|
# "data": {
|
13
17
|
# "cryptoCurrencyList": [
|
14
18
|
# {
|
@@ -81,42 +85,64 @@ module CoinmarketcapFree
|
|
81
85
|
# ],
|
82
86
|
# "totalCount": "8857"
|
83
87
|
# },
|
84
|
-
#
|
88
|
+
# "status": {
|
85
89
|
# "timestamp": "2023-01-08T15:33:30.271Z",
|
86
90
|
# "error_code": "0",
|
87
91
|
# "error_message": "SUCCESS",
|
88
92
|
# "elapsed": "2",
|
89
93
|
# "credit_count": 0
|
90
|
-
#
|
91
|
-
#
|
94
|
+
# }
|
95
|
+
# }
|
92
96
|
#
|
93
97
|
# 'data' - Results of your query returned as an object map.
|
94
|
-
#
|
95
|
-
#
|
98
|
+
# 'cryptoCurrencyList' - Array of cryptocurrency objects matching the list options.
|
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, sort_type:'asc')
|
105
|
+
#
|
106
|
+
# or
|
107
|
+
#
|
108
|
+
# list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
|
109
|
+
# list.sort_type = '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
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
# Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash. The primary options are:
|
118
|
+
#
|
119
|
+
# * <tt> start: </tt> - [Integer] Default: 1. Optionally offset the start (1-based index) of the paginated list of items to return.
|
120
|
+
# * <tt> limit: </tt> - [Integer] Default: 100. Optionally specify the number of results to return.
|
121
|
+
# Use this parameter and the "start" parameter to determine your own pagination size.
|
122
|
+
# * <tt> sort_by: </tt> - [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").
|
123
|
+
# What field to sort the list of cryptocurrencies by.
|
124
|
+
# * <tt> sort_type: </tt> - [String] Default: "desc". ("asc" or "desc"). The direction in which to order cryptocurrencies against the specified sort.
|
125
|
+
# * <tt> convert: </tt> - [String] Default: 'USD'. Default: 'USD'. Select cryptocurrencies to exchange
|
126
|
+
# ("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").
|
127
|
+
# For example, many 'USD,BTC,ETH' to convert or only one 'USD'
|
128
|
+
# * <tt> crypto_typ: </tt> - [String] Default: "all". ("all", "coins", "tokens"). The type of cryptocurrency to include.
|
129
|
+
# * <tt> tag_type: </tt> - [String] Default: "all". ("all", "defi", "filesharing"). The tag of cryptocurrency to include.
|
130
|
+
# * <tt> audited: </tt> - [FalseClass, TrueClass] Show audited (true) or not (false)
|
131
|
+
# * <tt> aux: </tt> - [String] Optionally specify a comma-separated list of supplemental data fields to return.
|
132
|
+
# 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.
|
133
|
+
# * <tt> tags: </tt> - [String] If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
134
|
+
# * <tt> volume_24h_range: </tt> - [String] Optionally specify a threshold 24 hour USD volume to filter results by.
|
135
|
+
# For example, For example, '0~100000000000000000'
|
136
|
+
# * <tt> percent_change_24h_range: </tt> - [String] Optionally specify a threshold 24 hour percent change to filter results by.
|
137
|
+
# For example, '0~100' or '-10~100'
|
138
|
+
# * <tt> circulating_supply_range: </tt> - [String] Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
139
|
+
# * <tt> price_range: </tt> - [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
140
|
+
# * <tt> market_cap_range: </tt> - [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
141
|
+
#
|
142
|
+
# @param [Hash] options
|
143
|
+
def initialize(**options)
|
144
|
+
@limit = options[:limit].nil? ? 100 : options[:limit] # Integer
|
145
|
+
@start = options[:start].nil? ? 1 : options[:start] # Integer
|
120
146
|
@sort_by = options[:sort_by] # String
|
121
147
|
@sort_type = options[:sort_type] # String
|
122
148
|
@convert = options[:convert] # String
|
@@ -148,6 +174,7 @@ module CoinmarketcapFree
|
|
148
174
|
:price_range,
|
149
175
|
:market_cap_range
|
150
176
|
|
177
|
+
private
|
151
178
|
def generate_uri_for_data
|
152
179
|
options = self.instance_variables
|
153
180
|
.select { |name_var| not self.instance_variable_get(name_var).nil? }
|
@@ -157,4 +184,4 @@ module CoinmarketcapFree
|
|
157
184
|
URI(query)
|
158
185
|
end
|
159
186
|
end
|
160
|
-
end
|
187
|
+
end
|
data/lib/coinmarketcap_free.rb
CHANGED
@@ -6,4 +6,203 @@ require_relative "coinmarketcap_free/base"
|
|
6
6
|
require_relative "coinmarketcap_free/version"
|
7
7
|
|
8
8
|
module CoinmarketcapFree
|
9
|
+
class << self
|
10
|
+
@@cryptocurrencies = Cryptocurrencies.new
|
11
|
+
@@coin = Coin.new
|
12
|
+
|
13
|
+
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
14
|
+
#
|
15
|
+
# history = CoinmarketcapFree.coins(1, '1D')
|
16
|
+
#
|
17
|
+
# Result json:
|
18
|
+
#
|
19
|
+
# {
|
20
|
+
# "data": {
|
21
|
+
# "points": {
|
22
|
+
# "1673192010": {
|
23
|
+
# "v": [
|
24
|
+
# 16953.771282696678,
|
25
|
+
# 7609543976.45,
|
26
|
+
# 326457581376.786557398500,
|
27
|
+
# 1,
|
28
|
+
# 19255750.00000000000000000000
|
29
|
+
# ],
|
30
|
+
# "c": [
|
31
|
+
# 16953.771282696678,
|
32
|
+
# 7609543976.45,
|
33
|
+
# 326457581376.786557398500
|
34
|
+
# ]
|
35
|
+
# },
|
36
|
+
# ...
|
37
|
+
# }
|
38
|
+
# },
|
39
|
+
# "status": {
|
40
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
41
|
+
# "error_code": "0",
|
42
|
+
# "error_message": "SUCCESS",
|
43
|
+
# "elapsed": "2",
|
44
|
+
# "credit_count": 0
|
45
|
+
# }
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# 'data' - Results of your query returned as an object map.
|
49
|
+
# 'points' - Price range history
|
50
|
+
# 'status' - Standardized status object for API calls.
|
51
|
+
#
|
52
|
+
# @param id [Integer] Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
|
53
|
+
# @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
54
|
+
# @return [String, nil]
|
55
|
+
def coin_history(id, range_time)
|
56
|
+
@@coin.id = id
|
57
|
+
@@coin.range_time = range_time
|
58
|
+
@@coin.update ? @@coin.get_data : nil
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get a list of cryptocurrencies
|
62
|
+
#
|
63
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1)
|
64
|
+
#
|
65
|
+
# Result json:
|
66
|
+
#
|
67
|
+
# {
|
68
|
+
# "data": {
|
69
|
+
# "cryptoCurrencyList": [
|
70
|
+
# {
|
71
|
+
# "id": 1,
|
72
|
+
# "name": "Bitcoin",
|
73
|
+
# "symbol": "BTC",
|
74
|
+
# "slug": "bitcoin",
|
75
|
+
# "tags": [
|
76
|
+
# "mineable",
|
77
|
+
# "pow",
|
78
|
+
# "sha-256",
|
79
|
+
# "store-of-value",
|
80
|
+
# "state-channel",
|
81
|
+
# "coinbase-ventures-portfolio",
|
82
|
+
# "three-arrows-capital-portfolio",
|
83
|
+
# "polychain-capital-portfolio",
|
84
|
+
# "binance-labs-portfolio",
|
85
|
+
# "blockchain-capital-portfolio",
|
86
|
+
# "boostvc-portfolio",
|
87
|
+
# "cms-holdings-portfolio",
|
88
|
+
# "dcg-portfolio",
|
89
|
+
# "dragonfly-capital-portfolio",
|
90
|
+
# "electric-capital-portfolio",
|
91
|
+
# "fabric-ventures-portfolio",
|
92
|
+
# "framework-ventures-portfolio",
|
93
|
+
# "galaxy-digital-portfolio",
|
94
|
+
# "huobi-capital-portfolio",
|
95
|
+
# "alameda-research-portfolio",
|
96
|
+
# "a16z-portfolio",
|
97
|
+
# "1confirmation-portfolio",
|
98
|
+
# "winklevoss-capital-portfolio",
|
99
|
+
# "usv-portfolio",
|
100
|
+
# "placeholder-ventures-portfolio",
|
101
|
+
# "pantera-capital-portfolio",
|
102
|
+
# "multicoin-capital-portfolio",
|
103
|
+
# "paradigm-portfolio"
|
104
|
+
# ],
|
105
|
+
# "cmcRank": 1,
|
106
|
+
# "marketPairCount": 9922,
|
107
|
+
# "circulatingSupply": 19256812.0,
|
108
|
+
# "selfReportedCirculatingSupply": 0,
|
109
|
+
# "totalSupply": 19256812.0,
|
110
|
+
# "maxSupply": 21000000.0,
|
111
|
+
# "isActive": 1,
|
112
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
113
|
+
# "dateAdded": "2013-04-28T00:00:00.000Z",
|
114
|
+
# "quotes": [
|
115
|
+
# {
|
116
|
+
# "name": "USD",
|
117
|
+
# "price": 17209.447088639048,
|
118
|
+
# "volume24h": 13652714044.770432,
|
119
|
+
# "marketCap": 331399087209.8695,
|
120
|
+
# "percentChange1h": -0.00692023,
|
121
|
+
# "percentChange24h": 1.50954046,
|
122
|
+
# "percentChange7d": 2.78181713,
|
123
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
124
|
+
# "percentChange30d": 0.30441134,
|
125
|
+
# "percentChange60d": 3.89490715,
|
126
|
+
# "percentChange90d": -9.99714982,
|
127
|
+
# "fullyDilluttedMarketCap": 361398388861.42,
|
128
|
+
# "marketCapByTotalSupply": 331399087209.8695,
|
129
|
+
# "dominance": 39.0828,
|
130
|
+
# "turnover": 0.0411972,
|
131
|
+
# "ytdPriceChangePercentage": 3.515
|
132
|
+
# }
|
133
|
+
# ],
|
134
|
+
# "isAudited": false
|
135
|
+
# }
|
136
|
+
# ...
|
137
|
+
# ],
|
138
|
+
# "totalCount": "8857"
|
139
|
+
# },
|
140
|
+
# "status": {
|
141
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
142
|
+
# "error_code": "0",
|
143
|
+
# "error_message": "SUCCESS",
|
144
|
+
# "elapsed": "2",
|
145
|
+
# "credit_count": 0
|
146
|
+
# }
|
147
|
+
# }
|
148
|
+
#
|
149
|
+
# 'data' - Results of your query returned as an object map.
|
150
|
+
# 'cryptoCurrencyList' - Array of cryptocurrency objects matching the list options.
|
151
|
+
# 'totalCount' - Total number of cryptocurrencies
|
152
|
+
# 'status' - Standardized status object for API calls.
|
153
|
+
#
|
154
|
+
# If you want to sort in ascending, just write parameter:
|
155
|
+
#
|
156
|
+
# list = CoinmarketcapFree.coins(limit: 100, start: 1, sort_type:'asc')
|
157
|
+
#
|
158
|
+
# Also see other parameters:
|
159
|
+
#
|
160
|
+
# * <tt> start: </tt> - [Integer] Default: 1. Optionally offset the start (1-based index) of the paginated list of items to return.
|
161
|
+
# * <tt> limit: </tt> - [Integer] Default: 100. Optionally specify the number of results to return.
|
162
|
+
# Use this parameter and the "start" parameter to determine your own pagination size.
|
163
|
+
# * <tt> sort_by: </tt> - [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").
|
164
|
+
# What field to sort the list of cryptocurrencies by.
|
165
|
+
# * <tt> sort_type: </tt> - [String] Default: "desc". ("asc" or "desc"). The direction in which to order cryptocurrencies against the specified sort.
|
166
|
+
# * <tt> convert: </tt> - [String] Default: 'USD'. Default: 'USD'. Select cryptocurrencies to exchange
|
167
|
+
# ("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").
|
168
|
+
# For example, many 'USD,BTC,ETH' to convert or only one 'USD'
|
169
|
+
# * <tt> crypto_typ: </tt> - [String] Default: "all". ("all", "coins", "tokens"). The type of cryptocurrency to include.
|
170
|
+
# * <tt> tag_type: </tt> - [String] Default: "all". ("all", "defi", "filesharing"). The tag of cryptocurrency to include.
|
171
|
+
# * <tt> audited: </tt> - [FalseClass, TrueClass] Show audited (true) or not (false)
|
172
|
+
# * <tt> aux: </tt> - [String] Optionally specify a comma-separated list of supplemental data fields to return.
|
173
|
+
# 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.
|
174
|
+
# * <tt> tags: </tt> - [String] If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
175
|
+
# * <tt> volume_24h_range: </tt> - [String] Optionally specify a threshold 24 hour USD volume to filter results by.
|
176
|
+
# For example, For example, '0~100000000000000000'
|
177
|
+
# * <tt> percent_change_24h_range: </tt> - [String] Optionally specify a threshold 24 hour percent change to filter results by.
|
178
|
+
# For example, '0~100' or '-10~100'
|
179
|
+
# * <tt> circulating_supply_range: </tt> - [String] Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
180
|
+
# * <tt> price_range: </tt> - [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
181
|
+
# * <tt> market_cap_range: </tt> - [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
182
|
+
#
|
183
|
+
# @param [Hash] options
|
184
|
+
# @return [String, nil]
|
185
|
+
def coins(**options)
|
186
|
+
@@cryptocurrencies.instance_variables.each do |var_name|
|
187
|
+
value = options[var_name.to_s.delete('@').to_sym]
|
188
|
+
@@cryptocurrencies.instance_variable_set(var_name, value) unless value.nil?
|
189
|
+
end
|
190
|
+
|
191
|
+
@@cryptocurrencies.update ? @@cryptocurrencies.get_data : nil
|
192
|
+
end
|
193
|
+
|
194
|
+
# Get coin logo URL from coinmarketcap
|
195
|
+
#
|
196
|
+
# logo = CoinmarketcapFree.img_coin(1, '64x64')
|
197
|
+
#
|
198
|
+
# Result:
|
199
|
+
# "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
200
|
+
#
|
201
|
+
# @return [String] Return URL from coinmarketcap
|
202
|
+
# @param [Integer] id_coin Identify coin. For example, bitcoin has 1
|
203
|
+
# @param [String] size Choose one size: 64x64, 128x128, 200x200
|
204
|
+
def img_coin(id_coin, size)
|
205
|
+
"https://s2.coinmarketcap.com/static/img/coins/#{size}/#{id_coin}.png"
|
206
|
+
end
|
207
|
+
end
|
9
208
|
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.2
|
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-23 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,6 @@ files:
|
|
32
32
|
- lib/coinmarketcap_free/cryptocurrencies.rb
|
33
33
|
- lib/coinmarketcap_free/helper.rb
|
34
34
|
- lib/coinmarketcap_free/version.rb
|
35
|
-
- sig/coinmarketcap_free.rbs
|
36
35
|
homepage: https://github.com/Cosmic-1/coinmarketcap_free
|
37
36
|
licenses:
|
38
37
|
- MIT
|
data/sig/coinmarketcap_free.rbs
DELETED