coinmarketcap_free 0.1.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 +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/coinmarketcap_free.iml +55 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +21 -0
- data/README.md +196 -0
- data/Rakefile +12 -0
- data/lib/coinmarketcap_free/base.rb +36 -0
- data/lib/coinmarketcap_free/coin.rb +62 -0
- data/lib/coinmarketcap_free/cryptocurrencies.rb +160 -0
- data/lib/coinmarketcap_free/helper.rb +6 -0
- data/lib/coinmarketcap_free/version.rb +5 -0
- data/lib/coinmarketcap_free.rb +9 -0
- data/sig/coinmarketcap_free.rbs +4 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a60b33c55857a5788638a00482a62c3a750f3f0a6534ccd7bc6cbeb30e2c504b
|
4
|
+
data.tar.gz: a150126723cfd1ecdde08bcecbbe583e8518de73824eea9a6a51f49c6fe12ee5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da80d4fd25bee02caad265440b49e41bdfd6bbe4028d45c44107d6158157728d8843bf29f5e59dc0ee459769bf040cb93bfc8ee091d28d21f20aab77776aa12e
|
7
|
+
data.tar.gz: d95a8f584081aa713d201b4edc4d5d90552940e8453c12ca32b2e42decb48c833f9b3f45c81b6c27d5792b10f37b6ac3022b39eda1481bda4d18e1b3f860cc9e
|
data/.idea/.gitignore
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="jdk" jdkName="Remote-rbenv: ruby-3.1.3-p185" jdkType="RUBY_SDK" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.26, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.16.3, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="net-http (v0.3.0, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="openssl (v3.0.1, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="uri (v0.12.0, Remote-rbenv: ruby-3.1.3-p185) [gem]" level="application" />
|
21
|
+
</component>
|
22
|
+
<component name="RakeTasksCache">
|
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>
|
53
|
+
</option>
|
54
|
+
</component>
|
55
|
+
</module>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/coinmarketcap_free.iml" filepath="$PROJECT_DIR$/.idea/coinmarketcap_free.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vcs.xml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in coinmarketcap_free.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'uri', "~> 0.12.0"
|
9
|
+
gem "net-http", "~> 0.3.0"
|
10
|
+
gem "openssl", "~> 3.0"
|
11
|
+
gem "json", "~> 2.6"
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "rake", "~> 13.0"
|
15
|
+
gem "minitest", "~> 5.0"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
coinmarketcap_free (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
json (2.6.2)
|
10
|
+
minitest (5.16.3)
|
11
|
+
net-http (0.3.0)
|
12
|
+
uri
|
13
|
+
openssl (3.0.1)
|
14
|
+
rake (13.0.6)
|
15
|
+
uri (0.12.0)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
x86_64-linux
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
coinmarketcap_free!
|
22
|
+
json (~> 2.6)
|
23
|
+
minitest (~> 5.0)
|
24
|
+
net-http (~> 0.3.0)
|
25
|
+
openssl (~> 3.0)
|
26
|
+
rake (~> 13.0)
|
27
|
+
uri (~> 0.12.0)
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
2.3.26
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 cosmic-1
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,196 @@
|
|
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
|
+
## Usage
|
16
|
+
``` Ruby
|
17
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1)
|
18
|
+
list.update
|
19
|
+
list.data
|
20
|
+
```
|
21
|
+
|
22
|
+
Result:
|
23
|
+
``` JSON
|
24
|
+
{
|
25
|
+
"data": {
|
26
|
+
"cryptoCurrencyList": [
|
27
|
+
{
|
28
|
+
"id": 1,
|
29
|
+
"name": "Bitcoin",
|
30
|
+
"symbol": "BTC",
|
31
|
+
"slug": "bitcoin",
|
32
|
+
"tags": [
|
33
|
+
"mineable",
|
34
|
+
"pow",
|
35
|
+
"sha-256",
|
36
|
+
"store-of-value",
|
37
|
+
"state-channel",
|
38
|
+
"coinbase-ventures-portfolio",
|
39
|
+
"three-arrows-capital-portfolio",
|
40
|
+
"polychain-capital-portfolio",
|
41
|
+
"binance-labs-portfolio",
|
42
|
+
"blockchain-capital-portfolio",
|
43
|
+
"boostvc-portfolio",
|
44
|
+
"cms-holdings-portfolio",
|
45
|
+
"dcg-portfolio",
|
46
|
+
"dragonfly-capital-portfolio",
|
47
|
+
"electric-capital-portfolio",
|
48
|
+
"fabric-ventures-portfolio",
|
49
|
+
"framework-ventures-portfolio",
|
50
|
+
"galaxy-digital-portfolio",
|
51
|
+
"huobi-capital-portfolio",
|
52
|
+
"alameda-research-portfolio",
|
53
|
+
"a16z-portfolio",
|
54
|
+
"1confirmation-portfolio",
|
55
|
+
"winklevoss-capital-portfolio",
|
56
|
+
"usv-portfolio",
|
57
|
+
"placeholder-ventures-portfolio",
|
58
|
+
"pantera-capital-portfolio",
|
59
|
+
"multicoin-capital-portfolio",
|
60
|
+
"paradigm-portfolio"
|
61
|
+
],
|
62
|
+
"cmcRank": 1,
|
63
|
+
"marketPairCount": 9922,
|
64
|
+
"circulatingSupply": 19256812.0,
|
65
|
+
"selfReportedCirculatingSupply": 0,
|
66
|
+
"totalSupply": 19256812.0,
|
67
|
+
"maxSupply": 21000000.0,
|
68
|
+
"isActive": 1,
|
69
|
+
"lastUpdated": "2023-01-09T08:25:00.000Z",
|
70
|
+
"dateAdded": "2013-04-28T00:00:00.000Z",
|
71
|
+
"quotes": [
|
72
|
+
{
|
73
|
+
"name": "USD",
|
74
|
+
"price": 17209.447088639048,
|
75
|
+
"volume24h": 13652714044.770432,
|
76
|
+
"marketCap": 331399087209.8695,
|
77
|
+
"percentChange1h": -0.00692023,
|
78
|
+
"percentChange24h": 1.50954046,
|
79
|
+
"percentChange7d": 2.78181713,
|
80
|
+
"lastUpdated": "2023-01-09T08:25:00.000Z",
|
81
|
+
"percentChange30d": 0.30441134,
|
82
|
+
"percentChange60d": 3.89490715,
|
83
|
+
"percentChange90d": -9.99714982,
|
84
|
+
"fullyDilluttedMarketCap": 361398388861.42,
|
85
|
+
"marketCapByTotalSupply": 331399087209.8695,
|
86
|
+
"dominance": 39.0828,
|
87
|
+
"turnover": 0.0411972,
|
88
|
+
"ytdPriceChangePercentage": 3.515
|
89
|
+
}
|
90
|
+
],
|
91
|
+
"isAudited": false
|
92
|
+
}
|
93
|
+
...
|
94
|
+
],
|
95
|
+
"totalCount": "8857"
|
96
|
+
},
|
97
|
+
"status": {
|
98
|
+
"timestamp": "2023-01-08T15:33:30.271Z",
|
99
|
+
"error_code": "0",
|
100
|
+
"error_message": "SUCCESS",
|
101
|
+
"elapsed": "2",
|
102
|
+
"credit_count": 0
|
103
|
+
}
|
104
|
+
}
|
105
|
+
```
|
106
|
+
|
107
|
+
### If you want to sort in ascending, just write parameter:
|
108
|
+
|
109
|
+
``` Ruby
|
110
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1, sort_type:'asc')
|
111
|
+
```
|
112
|
+
or
|
113
|
+
``` Ruby
|
114
|
+
list = CoinmarketcapFree::Cryptocurrencies.new(100, 1)
|
115
|
+
list.sort_type = 'asc'
|
116
|
+
```
|
117
|
+
|
118
|
+
Also other parameters for Cryptocurrencies:
|
119
|
+
|
120
|
+
| Name | Type | Description |
|
121
|
+
|:--------------------------------|:---------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
122
|
+
| ```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. |
|
123
|
+
| ```sort_type:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. |
|
124
|
+
| ```convert:``` | String. | Default: ```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
|
+
| ```crypto_type:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. |
|
126
|
+
| ```tag_type:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. |
|
127
|
+
| ```audited:``` | Boolean. | false or true |
|
128
|
+
| ```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. |
|
129
|
+
| ```tags:``` | String. | Default: ```mineable```. |
|
130
|
+
| ```volume_24h_range:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. For example, For example, ```0~100000000000000000``` |
|
131
|
+
| ```percent_change_24h_range:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. For example, ```0~100``` or ```-10~100``` |
|
132
|
+
| ```circulating_supply_range:``` | String. | Optionally specify a threshold circulating supply to filter results by. For example, ```0~100000000000000000``` |
|
133
|
+
| ```price_range:``` | String. | Optionally specify a threshold USD price to filter results by. For example, ```0~100000000000000000``` |
|
134
|
+
| ```market_cap_range:``` | String. | Optionally specify a threshold market cap to filter results by. For example, ```0~100000000000000000``` |
|
135
|
+
|
136
|
+
### Returns an interval of historic market quotes:
|
137
|
+
|
138
|
+
``` Ruby
|
139
|
+
coin = CoinmarketcapFree::Coin.new(1, '1D')
|
140
|
+
coin.update
|
141
|
+
coin.data
|
142
|
+
```
|
143
|
+
|
144
|
+
Result:
|
145
|
+
``` JSON
|
146
|
+
{
|
147
|
+
"data": {
|
148
|
+
"points": {
|
149
|
+
"1673192010": {
|
150
|
+
"v": [
|
151
|
+
16953.771282696678,
|
152
|
+
7609543976.45,
|
153
|
+
326457581376.786557398500,
|
154
|
+
1,
|
155
|
+
19255750.00000000000000000000
|
156
|
+
],
|
157
|
+
"c": [
|
158
|
+
16953.771282696678,
|
159
|
+
7609543976.45,
|
160
|
+
326457581376.786557398500
|
161
|
+
]
|
162
|
+
},
|
163
|
+
...
|
164
|
+
}
|
165
|
+
},
|
166
|
+
"status": {
|
167
|
+
"timestamp": "2023-01-08T15:33:30.271Z",
|
168
|
+
"error_code": "0",
|
169
|
+
"error_message": "SUCCESS",
|
170
|
+
"elapsed": "2",
|
171
|
+
"credit_count": 0
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
Parameters for Coin:
|
178
|
+
|
179
|
+
| Name | Type | Description |
|
180
|
+
|:-----------------|:---------|:--------------------------------------------------------------------------------------------------------------------------------------------|
|
181
|
+
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1 |
|
182
|
+
| ```range_time``` | String. | Range time. For example, ```1D```, ```7D```, ```1M```, ```3M```, ```1Y```, ```YTD```, ```ALL``` or custom range ```1668981600~1671659999``` |
|
183
|
+
|
184
|
+
## Development
|
185
|
+
|
186
|
+
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.
|
187
|
+
|
188
|
+
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).
|
189
|
+
|
190
|
+
## Contributing
|
191
|
+
|
192
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cosmic-1/coinmarketcap_free.
|
193
|
+
|
194
|
+
## License
|
195
|
+
|
196
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'coinmarketcap_free/helper'
|
4
|
+
|
5
|
+
module CoinmarketcapFree
|
6
|
+
class BASE
|
7
|
+
protected
|
8
|
+
|
9
|
+
def request_to_read_data(url)
|
10
|
+
response = Net::HTTP.get_response(url, Hash('Accept': '*/*'))
|
11
|
+
|
12
|
+
raise HTTPBadResponse if response.code.match? /[45][0-9]{2}/
|
13
|
+
|
14
|
+
response.read_body
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_uri_for_data
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
attr_reader :data
|
24
|
+
|
25
|
+
def update
|
26
|
+
begin
|
27
|
+
url = generate_uri_for_data
|
28
|
+
@data = request_to_read_data(url)
|
29
|
+
rescue
|
30
|
+
false
|
31
|
+
else
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'coinmarketcap_free/helper'
|
4
|
+
require 'coinmarketcap_free/base'
|
5
|
+
|
6
|
+
module CoinmarketcapFree
|
7
|
+
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
8
|
+
#
|
9
|
+
# For example, json data
|
10
|
+
#
|
11
|
+
# {
|
12
|
+
# "data": {
|
13
|
+
# "points": {
|
14
|
+
# "1673192010": {
|
15
|
+
# "v": [
|
16
|
+
# 16953.771282696678,
|
17
|
+
# 7609543976.45,
|
18
|
+
# 326457581376.786557398500,
|
19
|
+
# 1,
|
20
|
+
# 19255750.00000000000000000000
|
21
|
+
# ],
|
22
|
+
# "c": [
|
23
|
+
# 16953.771282696678,
|
24
|
+
# 7609543976.45,
|
25
|
+
# 326457581376.786557398500
|
26
|
+
# ]
|
27
|
+
# },
|
28
|
+
# ...
|
29
|
+
# }
|
30
|
+
# },
|
31
|
+
# "status": {
|
32
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
33
|
+
# "error_code": "0",
|
34
|
+
# "error_message": "SUCCESS",
|
35
|
+
# "elapsed": "2",
|
36
|
+
# "credit_count": 0
|
37
|
+
# }
|
38
|
+
# }
|
39
|
+
#
|
40
|
+
# 'data' - Results of your query returned as an object map.
|
41
|
+
# 'points' - Price range history
|
42
|
+
# 'status' - Standardized status object for API calls.
|
43
|
+
class Coin < BASE
|
44
|
+
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/chart'.freeze
|
45
|
+
private_constant :URL_API
|
46
|
+
|
47
|
+
attr_accessor :id,
|
48
|
+
:range_time
|
49
|
+
|
50
|
+
# id Integer. Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
|
51
|
+
# range_time String. Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
52
|
+
def initialize(id, range_time)
|
53
|
+
@id = id
|
54
|
+
@range_time = range_time
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_uri_for_data
|
58
|
+
query = "#{URL_API}?id=#{id}&range=#{range_time}"
|
59
|
+
URI(query)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'coinmarketcap_free/helper'
|
4
|
+
require 'coinmarketcap_free/base'
|
5
|
+
|
6
|
+
module CoinmarketcapFree
|
7
|
+
# Get a list of cryptocurrencies
|
8
|
+
#
|
9
|
+
# For example, result json data
|
10
|
+
#
|
11
|
+
# {
|
12
|
+
# "data": {
|
13
|
+
# "cryptoCurrencyList": [
|
14
|
+
# {
|
15
|
+
# "id": 1,
|
16
|
+
# "name": "Bitcoin",
|
17
|
+
# "symbol": "BTC",
|
18
|
+
# "slug": "bitcoin",
|
19
|
+
# "tags": [
|
20
|
+
# "mineable",
|
21
|
+
# "pow",
|
22
|
+
# "sha-256",
|
23
|
+
# "store-of-value",
|
24
|
+
# "state-channel",
|
25
|
+
# "coinbase-ventures-portfolio",
|
26
|
+
# "three-arrows-capital-portfolio",
|
27
|
+
# "polychain-capital-portfolio",
|
28
|
+
# "binance-labs-portfolio",
|
29
|
+
# "blockchain-capital-portfolio",
|
30
|
+
# "boostvc-portfolio",
|
31
|
+
# "cms-holdings-portfolio",
|
32
|
+
# "dcg-portfolio",
|
33
|
+
# "dragonfly-capital-portfolio",
|
34
|
+
# "electric-capital-portfolio",
|
35
|
+
# "fabric-ventures-portfolio",
|
36
|
+
# "framework-ventures-portfolio",
|
37
|
+
# "galaxy-digital-portfolio",
|
38
|
+
# "huobi-capital-portfolio",
|
39
|
+
# "alameda-research-portfolio",
|
40
|
+
# "a16z-portfolio",
|
41
|
+
# "1confirmation-portfolio",
|
42
|
+
# "winklevoss-capital-portfolio",
|
43
|
+
# "usv-portfolio",
|
44
|
+
# "placeholder-ventures-portfolio",
|
45
|
+
# "pantera-capital-portfolio",
|
46
|
+
# "multicoin-capital-portfolio",
|
47
|
+
# "paradigm-portfolio"
|
48
|
+
# ],
|
49
|
+
# "cmcRank": 1,
|
50
|
+
# "marketPairCount": 9922,
|
51
|
+
# "circulatingSupply": 19256812.0,
|
52
|
+
# "selfReportedCirculatingSupply": 0,
|
53
|
+
# "totalSupply": 19256812.0,
|
54
|
+
# "maxSupply": 21000000.0,
|
55
|
+
# "isActive": 1,
|
56
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
57
|
+
# "dateAdded": "2013-04-28T00:00:00.000Z",
|
58
|
+
# "quotes": [
|
59
|
+
# {
|
60
|
+
# "name": "USD",
|
61
|
+
# "price": 17209.447088639048,
|
62
|
+
# "volume24h": 13652714044.770432,
|
63
|
+
# "marketCap": 331399087209.8695,
|
64
|
+
# "percentChange1h": -0.00692023,
|
65
|
+
# "percentChange24h": 1.50954046,
|
66
|
+
# "percentChange7d": 2.78181713,
|
67
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
68
|
+
# "percentChange30d": 0.30441134,
|
69
|
+
# "percentChange60d": 3.89490715,
|
70
|
+
# "percentChange90d": -9.99714982,
|
71
|
+
# "fullyDilluttedMarketCap": 361398388861.42,
|
72
|
+
# "marketCapByTotalSupply": 331399087209.8695,
|
73
|
+
# "dominance": 39.0828,
|
74
|
+
# "turnover": 0.0411972,
|
75
|
+
# "ytdPriceChangePercentage": 3.515
|
76
|
+
# }
|
77
|
+
# ],
|
78
|
+
# "isAudited": false
|
79
|
+
# }
|
80
|
+
# ...
|
81
|
+
# ],
|
82
|
+
# "totalCount": "8857"
|
83
|
+
# },
|
84
|
+
# "status": {
|
85
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
86
|
+
# "error_code": "0",
|
87
|
+
# "error_message": "SUCCESS",
|
88
|
+
# "elapsed": "2",
|
89
|
+
# "credit_count": 0
|
90
|
+
# }
|
91
|
+
# }
|
92
|
+
#
|
93
|
+
# 'data' - Results of your query returned as an object map.
|
94
|
+
# 'cryptoCurrencyList' - Array of cryptocurrency objects matching the list options.
|
95
|
+
# 'totalCount' - Total number of cryptocurrencies
|
96
|
+
# 'status' - Standardized status object for API calls.
|
97
|
+
class Cryptocurrencies < BASE
|
98
|
+
|
99
|
+
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'.freeze
|
100
|
+
private_constant :URL_API
|
101
|
+
|
102
|
+
# start: Integer. Default: 1 | Optionally offset the start (1-based index) of the paginated list of items to return.
|
103
|
+
# limit: Integer. Default: 100 | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size.
|
104
|
+
# 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.
|
105
|
+
# sort_type: String. Default: "desc". ("asc" or "desc"). The direction in which to order cryptocurrencies against the specified sort.
|
106
|
+
# convert: String. Default: 'USD'. Default: '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'
|
107
|
+
# crypto_type: String. Default: "all". ("all", "coins", "tokens"). The type of cryptocurrency to include.
|
108
|
+
# tag_type: String. Default: "all". ("all", "defi", "filesharing"). The tag of cryptocurrency to include.
|
109
|
+
# audited: Boolean. false or true
|
110
|
+
# 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.
|
111
|
+
# tags: String. Usually choose 'mineable'.
|
112
|
+
# volume_24h_range: String. Optionally specify a threshold 24 hour USD volume to filter results by. For example, For example, '0~100000000000000000'
|
113
|
+
# percent_change_24h_range: String. Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
|
114
|
+
# circulating_supply_range: String. Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
115
|
+
# price_range: String. Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
116
|
+
# market_cap_range: String. Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
117
|
+
def initialize(limit = 100, start = 1, **options)
|
118
|
+
@limit = limit # Integer
|
119
|
+
@start = start # Integer
|
120
|
+
@sort_by = options[:sort_by] # String
|
121
|
+
@sort_type = options[:sort_type] # String
|
122
|
+
@convert = options[:convert] # String
|
123
|
+
@crypto_type = options[:crypto_type] # String
|
124
|
+
@tag_type = options[:tag_type] # String
|
125
|
+
@audited = options[:audited] # Boolean
|
126
|
+
@aux = options[:aux] # String
|
127
|
+
@tags = options[:tags] # String
|
128
|
+
@volume_24h_range = options[:volume_24h_range] # String
|
129
|
+
@percent_change_24h_range = options[:percent_change_24h_range] # String
|
130
|
+
@circulating_supply_range = options[:circulating_supply_range] # String
|
131
|
+
@price_range = options[:price_range] # String
|
132
|
+
@market_cap_range = options[:market_cap_range] # String
|
133
|
+
end
|
134
|
+
|
135
|
+
attr_accessor :limit,
|
136
|
+
:start,
|
137
|
+
:sort_by,
|
138
|
+
:sort_type,
|
139
|
+
:convert,
|
140
|
+
:crypto_type,
|
141
|
+
:tag_type,
|
142
|
+
:audited,
|
143
|
+
:aux,
|
144
|
+
:tags,
|
145
|
+
:volume_24h_range,
|
146
|
+
:percent_change_24h_range,
|
147
|
+
:circulating_supply_range,
|
148
|
+
:price_range,
|
149
|
+
:market_cap_range
|
150
|
+
|
151
|
+
def generate_uri_for_data
|
152
|
+
options = self.instance_variables
|
153
|
+
.select { |name_var| not self.instance_variable_get(name_var).nil? }
|
154
|
+
.map {|name_var| "#{name_var.to_s.delete('@')}=#{self.instance_variable_get(name_var)}"}
|
155
|
+
|
156
|
+
query = "#{URL_API}?#{options.join('&')}"
|
157
|
+
URI(query)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coinmarketcap_free
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cosmic-1
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Cryptocurrency information from the Coinmarketcap site without a key.
|
14
|
+
email:
|
15
|
+
- crossdoh@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".idea/.gitignore"
|
21
|
+
- ".idea/coinmarketcap_free.iml"
|
22
|
+
- ".idea/modules.xml"
|
23
|
+
- ".idea/vcs.xml"
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/coinmarketcap_free.rb
|
30
|
+
- lib/coinmarketcap_free/base.rb
|
31
|
+
- lib/coinmarketcap_free/coin.rb
|
32
|
+
- lib/coinmarketcap_free/cryptocurrencies.rb
|
33
|
+
- lib/coinmarketcap_free/helper.rb
|
34
|
+
- lib/coinmarketcap_free/version.rb
|
35
|
+
- sig/coinmarketcap_free.rbs
|
36
|
+
homepage: https://github.com/Cosmic-1/coinmarketcap_free
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata:
|
40
|
+
allowed_push_host: https://rubygems.org
|
41
|
+
source_code_uri: https://github.com/Cosmic-1/coinmarketcap_free
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.6.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.3.26
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Cryptocurrency information from the Coinmarketcap site without a key.
|
61
|
+
test_files: []
|