coinmarketcap_free 0.1.4 → 0.2.0
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/.rubocop.yml +204 -0
- data/Gemfile +16 -16
- data/Gemfile.lock +30 -30
- data/LICENSE.txt +21 -21
- data/README.md +236 -227
- data/Rakefile +12 -12
- data/coinmarketcap_free.gemspec +37 -0
- data/lib/coinmarketcap_free/coin.rb +161 -64
- data/lib/coinmarketcap_free/coin_history.rb +108 -0
- data/lib/coinmarketcap_free/helper.rb +24 -6
- data/lib/coinmarketcap_free/icon.rb +28 -0
- data/lib/coinmarketcap_free/version.rb +5 -5
- data/lib/coinmarketcap_free.rb +10 -303
- metadata +8 -9
- data/.idea/.gitignore +0 -8
- data/.idea/coinmarketcap_free.iml +0 -27
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -6
- data/lib/coinmarketcap_free/base.rb +0 -42
- data/lib/coinmarketcap_free/cryptocurrencies.rb +0 -192
data/README.md
CHANGED
@@ -1,227 +1,236 @@
|
|
1
|
-
# CoinmarketcapFree
|
2
|
-
|
3
|
-
Cryptocurrency information from the Coinmarketcap site without a key.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Install the gem and add to the application's Gemfile by executing:
|
8
|
-
|
9
|
-
$ bundle add coinmarketcap_free
|
10
|
-
|
11
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
-
|
13
|
-
$ gem install coinmarketcap_free
|
14
|
-
|
15
|
-
##
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
```
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
"
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
"
|
82
|
-
"
|
83
|
-
"
|
84
|
-
"
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
```
|
135
|
-
|
136
|
-
```
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
|
142
|
-
|
143
|
-
| ```
|
144
|
-
| ```
|
145
|
-
| ```
|
146
|
-
| ```
|
147
|
-
| ```
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
coin = CoinmarketcapFree::
|
165
|
-
coin.
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
16953.771282696678,
|
183
|
-
7609543976.45,
|
184
|
-
326457581376.786557398500
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
}
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
```
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
1
|
+
# CoinmarketcapFree
|
2
|
+
|
3
|
+
Cryptocurrency information from the Coinmarketcap site without a key.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add coinmarketcap_free
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install coinmarketcap_free
|
14
|
+
|
15
|
+
## How to use?
|
16
|
+
|
17
|
+
``` Ruby
|
18
|
+
list = CoinmarketcapFree::Coin.list
|
19
|
+
```
|
20
|
+
|
21
|
+
Result:
|
22
|
+
``` JSON
|
23
|
+
{
|
24
|
+
"data": {
|
25
|
+
"cryptoCurrencyList": [
|
26
|
+
{
|
27
|
+
"id": 1,
|
28
|
+
"name": "Bitcoin",
|
29
|
+
"symbol": "BTC",
|
30
|
+
"slug": "bitcoin",
|
31
|
+
"tags": [
|
32
|
+
"mineable",
|
33
|
+
"pow",
|
34
|
+
"sha-256",
|
35
|
+
"store-of-value",
|
36
|
+
"state-channel",
|
37
|
+
"coinbase-ventures-portfolio",
|
38
|
+
"three-arrows-capital-portfolio",
|
39
|
+
"polychain-capital-portfolio",
|
40
|
+
"binance-labs-portfolio",
|
41
|
+
"blockchain-capital-portfolio",
|
42
|
+
"boostvc-portfolio",
|
43
|
+
"cms-holdings-portfolio",
|
44
|
+
"dcg-portfolio",
|
45
|
+
"dragonfly-capital-portfolio",
|
46
|
+
"electric-capital-portfolio",
|
47
|
+
"fabric-ventures-portfolio",
|
48
|
+
"framework-ventures-portfolio",
|
49
|
+
"galaxy-digital-portfolio",
|
50
|
+
"huobi-capital-portfolio",
|
51
|
+
"alameda-research-portfolio",
|
52
|
+
"a16z-portfolio",
|
53
|
+
"1confirmation-portfolio",
|
54
|
+
"winklevoss-capital-portfolio",
|
55
|
+
"usv-portfolio",
|
56
|
+
"placeholder-ventures-portfolio",
|
57
|
+
"pantera-capital-portfolio",
|
58
|
+
"multicoin-capital-portfolio",
|
59
|
+
"paradigm-portfolio"
|
60
|
+
],
|
61
|
+
"cmcRank": 1,
|
62
|
+
"marketPairCount": 9922,
|
63
|
+
"circulatingSupply": 19256812.0,
|
64
|
+
"selfReportedCirculatingSupply": 0,
|
65
|
+
"totalSupply": 19256812.0,
|
66
|
+
"maxSupply": 21000000.0,
|
67
|
+
"isActive": 1,
|
68
|
+
"lastUpdated": "2023-01-09T08:25:00.000Z",
|
69
|
+
"dateAdded": "2013-04-28T00:00:00.000Z",
|
70
|
+
"quotes": [
|
71
|
+
{
|
72
|
+
"name": "USD",
|
73
|
+
"price": 17209.447088639048,
|
74
|
+
"volume24h": 13652714044.770432,
|
75
|
+
"marketCap": 331399087209.8695,
|
76
|
+
"percentChange1h": -0.00692023,
|
77
|
+
"percentChange24h": 1.50954046,
|
78
|
+
"percentChange7d": 2.78181713,
|
79
|
+
"lastUpdated": "2023-01-09T08:25:00.000Z",
|
80
|
+
"percentChange30d": 0.30441134,
|
81
|
+
"percentChange60d": 3.89490715,
|
82
|
+
"percentChange90d": -9.99714982,
|
83
|
+
"fullyDilluttedMarketCap": 361398388861.42,
|
84
|
+
"marketCapByTotalSupply": 331399087209.8695,
|
85
|
+
"dominance": 39.0828,
|
86
|
+
"turnover": 0.0411972,
|
87
|
+
"ytdPriceChangePercentage": 3.515
|
88
|
+
}
|
89
|
+
],
|
90
|
+
"isAudited": false
|
91
|
+
}
|
92
|
+
...
|
93
|
+
],
|
94
|
+
"totalCount": "8857"
|
95
|
+
},
|
96
|
+
"status": {
|
97
|
+
"timestamp": "2023-01-08T15:33:30.271Z",
|
98
|
+
"error_code": "0",
|
99
|
+
"error_message": "SUCCESS",
|
100
|
+
"elapsed": "2",
|
101
|
+
"credit_count": 0
|
102
|
+
}
|
103
|
+
}
|
104
|
+
```
|
105
|
+
|
106
|
+
If you want to sort in ascending, just write parameter:
|
107
|
+
|
108
|
+
``` Ruby
|
109
|
+
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc')
|
110
|
+
```
|
111
|
+
|
112
|
+
You can also adding sort by:
|
113
|
+
|
114
|
+
``` Ruby
|
115
|
+
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
|
116
|
+
```
|
117
|
+
|
118
|
+
Convert all cryptocurrencies to USD,BTC,ETH:
|
119
|
+
|
120
|
+
``` Ruby
|
121
|
+
list = CoinmarketcapFree::Coin.list(limit: 100,
|
122
|
+
start: 1,
|
123
|
+
sort_type:'asc',
|
124
|
+
sort_by: 'name',
|
125
|
+
convert: 'USD,BTC,ETH')
|
126
|
+
```
|
127
|
+
|
128
|
+
|
129
|
+
Parameters for CoinmarketcapFree::Coin.list:
|
130
|
+
|
131
|
+
| Name | Type | Description | Examples |
|
132
|
+
|:------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
|
133
|
+
| ```limit:``` | Integer. | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size. ||
|
134
|
+
| ```start:``` | Integer. | Optionally offset the start (1-based index) of the paginated list of items to return. ||
|
135
|
+
| ```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. ||
|
136
|
+
| ```sort_type:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. ||
|
137
|
+
| ```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``` |
|
138
|
+
| ```crypto_type:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. ||
|
139
|
+
| ```tag_type:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. ||
|
140
|
+
| ```audited:``` | Boolean. | Show audited (true) or not (false) ||
|
141
|
+
| ```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``` |
|
142
|
+
| ```tags:``` | string. | If you want to see cryptocurrencies that can be mined, just type ```mineable```. ||
|
143
|
+
| ```volume24h_range:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. | ```0~100000000000000000``` |
|
144
|
+
| ```percent_change24h_range:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. | ```0~100``` or ```-10~100``` |
|
145
|
+
| ```circulating_supply_range:``` | String. | Optionally specify a threshold circulating supply to filter results by. | ```0~100000000000000000``` |
|
146
|
+
| ```price_range:``` | String. | Optionally specify a threshold USD price to filter results by. | ```0~100000000000000000``` |
|
147
|
+
| ```market_cap_range:``` | String. | Optionally specify a threshold market cap to filter results by. | ```0~100000000000000000``` |
|
148
|
+
|
149
|
+
### Returns an interval of historic market quotes:
|
150
|
+
|
151
|
+
``` Ruby
|
152
|
+
coin = CoinmarketcapFree::CoinHistory.custom_time(1, '1D')
|
153
|
+
coin = CoinmarketcapFree::CoinHistory.custom_time(1, '1668981600~1671659999')
|
154
|
+
```
|
155
|
+
|
156
|
+
or
|
157
|
+
|
158
|
+
``` Ruby
|
159
|
+
coin = CoinmarketcapFree::CoinHistory.interval_day(1)
|
160
|
+
coin = CoinmarketcapFree::CoinHistory.interval_seven_days(1)
|
161
|
+
coin = CoinmarketcapFree::CoinHistory.interval_one_month(1)
|
162
|
+
coin = CoinmarketcapFree::CoinHistory.interval_three_months(1)
|
163
|
+
coin = CoinmarketcapFree::CoinHistory.interval_one_year(1)
|
164
|
+
coin = CoinmarketcapFree::CoinHistory.interval_current_year(1)
|
165
|
+
coin = CoinmarketcapFree::CoinHistory.interval_all_time(1)
|
166
|
+
```
|
167
|
+
|
168
|
+
Result:
|
169
|
+
``` JSON
|
170
|
+
{
|
171
|
+
"data": {
|
172
|
+
"points": {
|
173
|
+
"1673192010": {
|
174
|
+
"v": [
|
175
|
+
16953.771282696678,
|
176
|
+
7609543976.45,
|
177
|
+
326457581376.786557398500,
|
178
|
+
1,
|
179
|
+
19255750.00000000000000000000
|
180
|
+
],
|
181
|
+
"c": [
|
182
|
+
16953.771282696678,
|
183
|
+
7609543976.45,
|
184
|
+
326457581376.786557398500
|
185
|
+
]
|
186
|
+
},
|
187
|
+
...
|
188
|
+
}
|
189
|
+
},
|
190
|
+
"status": {
|
191
|
+
"timestamp": "2023-01-08T15:33:30.271Z",
|
192
|
+
"error_code": "0",
|
193
|
+
"error_message": "SUCCESS",
|
194
|
+
"elapsed": "2",
|
195
|
+
"credit_count": 0
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
Parameters for CoinmarketcapFree::CoinHistory.custom_time:
|
202
|
+
|
203
|
+
| Name | Type | Description | Examples |
|
204
|
+
|:-----------------|:---------|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|
|
205
|
+
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
206
|
+
| ```range_time``` | String. | Range time. | ```1D```, ```7D```, ```1M```, ```3M```, ```1Y```, ```YTD```, ```ALL``` or custom range ```1668981600~1671659999``` |
|
207
|
+
|
208
|
+
### Generation a link to access the picture:
|
209
|
+
|
210
|
+
``` Ruby
|
211
|
+
logo_coin_url = CoinmarketcapFree::Icon.generate_url(1, 64)
|
212
|
+
```
|
213
|
+
|
214
|
+
``` Ruby
|
215
|
+
"https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
216
|
+
```
|
217
|
+
|
218
|
+
| Name | Type | Description | Examples |
|
219
|
+
|:-----------------|:---------|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|
|
220
|
+
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
221
|
+
| ```size``` | Integer. | Choose one size: 64, 128, 200. | If choose 64, it means 64x64 |
|
222
|
+
|
223
|
+
|
224
|
+
## Development
|
225
|
+
|
226
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
227
|
+
|
228
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
229
|
+
|
230
|
+
## Contributing
|
231
|
+
|
232
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cosmic-1/coinmarketcap_free.
|
233
|
+
|
234
|
+
## License
|
235
|
+
|
236
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rake/testtask"
|
5
|
-
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs << "test"
|
8
|
-
t.libs << "lib"
|
9
|
-
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
-
end
|
11
|
-
|
12
|
-
task default: :test
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: :test
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/coinmarketcap_free/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "coinmarketcap_free"
|
7
|
+
spec.version = CoinmarketcapFree::VERSION
|
8
|
+
spec.authors = ["cosmic-1"]
|
9
|
+
spec.email = ["crossdoh@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Cryptocurrency information from the Coinmarketcap site without a key."
|
12
|
+
spec.description = "Cryptocurrency information from the Coinmarketcap site without a key."
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["source_code_uri"] = 'https://github.com/Cosmic-1/coinmarketcap_free'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
# Uncomment to register a new dependency of your gem
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, check out our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
37
|
+
end
|