coinmarketcap_free 0.1.3 → 0.1.5
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 +16 -16
- data/Gemfile.lock +30 -30
- data/LICENSE.txt +21 -21
- data/README.md +216 -227
- data/Rakefile +12 -12
- data/lib/coinmarketcap_free/coin_history.rb +109 -0
- data/lib/coinmarketcap_free/coins.rb +176 -0
- data/lib/coinmarketcap_free/helper.rb +22 -6
- data/lib/coinmarketcap_free/icons.rb +28 -0
- data/lib/coinmarketcap_free/version.rb +5 -5
- data/lib/coinmarketcap_free.rb +10 -216
- metadata +5 -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/coin.rb +0 -129
- data/lib/coinmarketcap_free/cryptocurrencies.rb +0 -179
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,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
module CoinmarketcapFree
|
6
|
+
# All history cryptocurrency and their prices.
|
7
|
+
module CoinHistory
|
8
|
+
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/chart'
|
9
|
+
private_constant :URL_API
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
13
|
+
#
|
14
|
+
# history = CoinmarketcapFree::CoinHistory.custom_time(1, '1D')
|
15
|
+
#
|
16
|
+
# Result json:
|
17
|
+
#
|
18
|
+
# {
|
19
|
+
# "data": {
|
20
|
+
# "points": {
|
21
|
+
# "1673192010": {
|
22
|
+
# "v": [
|
23
|
+
# 16953.771282696678,
|
24
|
+
# 7609543976.45,
|
25
|
+
# 326457581376.786557398500,
|
26
|
+
# 1,
|
27
|
+
# 19255750.00000000000000000000
|
28
|
+
# ],
|
29
|
+
# "c": [
|
30
|
+
# 16953.771282696678,
|
31
|
+
# 7609543976.45,
|
32
|
+
# 326457581376.786557398500
|
33
|
+
# ]
|
34
|
+
# },
|
35
|
+
# ...
|
36
|
+
# }
|
37
|
+
# },
|
38
|
+
# "status": {
|
39
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
40
|
+
# "error_code": "0",
|
41
|
+
# "error_message": "SUCCESS",
|
42
|
+
# "elapsed": "2",
|
43
|
+
# "credit_count": 0
|
44
|
+
# }
|
45
|
+
# }
|
46
|
+
#
|
47
|
+
# 'data' - Results of your query returned as an object map.
|
48
|
+
# 'points' - Price range history
|
49
|
+
# 'status' - Standardized status object for API calls.
|
50
|
+
#
|
51
|
+
# @param id [Integer] Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
|
52
|
+
# @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
53
|
+
# @return [String]
|
54
|
+
def custom_time(id, range_time)
|
55
|
+
uri = Helper.generate_uri_for_data(URL_API, { id: id, range: range_time })
|
56
|
+
Helper.request_to_read_data(uri)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns an interval of historic for the day
|
60
|
+
#
|
61
|
+
# @param [Integer] id Cryptocurrency identifier
|
62
|
+
def interval_day(id)
|
63
|
+
custom_time(id, '1D')
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns an interval of historic for the seven days
|
67
|
+
#
|
68
|
+
# @param [Integer] id Cryptocurrency identifier
|
69
|
+
def interval_seven_days(id)
|
70
|
+
custom_time(id, '7D')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns an interval of historic for the one month
|
74
|
+
#
|
75
|
+
# @param [Integer] id Cryptocurrency identifier
|
76
|
+
def interval_one_month(id)
|
77
|
+
custom_time(id, '1M')
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns an interval of historic for the three months
|
81
|
+
#
|
82
|
+
# @param [Integer] id Cryptocurrency identifier
|
83
|
+
def interval_three_months(id)
|
84
|
+
custom_time(id, '3M')
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns an interval of historic for the one year
|
88
|
+
#
|
89
|
+
# @param [Integer] id Cryptocurrency identifier
|
90
|
+
def interval_one_year(id)
|
91
|
+
custom_time(id, '1Y')
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns an interval of historic for the current year
|
95
|
+
#
|
96
|
+
# @param [Integer] id Cryptocurrency identifier
|
97
|
+
def interval_current_year(id)
|
98
|
+
custom_time(id, 'YTD')
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns an interval of historic for the current year
|
102
|
+
#
|
103
|
+
# @param [Integer] id Cryptocurrency identifier
|
104
|
+
def interval_all_time(id)
|
105
|
+
custom_time(id, 'ALL')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
module CoinmarketcapFree
|
6
|
+
# All about cryptocurrencies and their prices.
|
7
|
+
module Coins
|
8
|
+
URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'
|
9
|
+
private_constant :URL_API
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Get a list of cryptocurrencies
|
13
|
+
#
|
14
|
+
# list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1)
|
15
|
+
#
|
16
|
+
# Result json:
|
17
|
+
#
|
18
|
+
# {
|
19
|
+
# "data": {
|
20
|
+
# "cryptoCurrencyList": [
|
21
|
+
# {
|
22
|
+
# "id": 1,
|
23
|
+
# "name": "Bitcoin",
|
24
|
+
# "symbol": "BTC",
|
25
|
+
# "slug": "bitcoin",
|
26
|
+
# "tags": [
|
27
|
+
# "mineable",
|
28
|
+
# "pow",
|
29
|
+
# "sha-256",
|
30
|
+
# "store-of-value",
|
31
|
+
# "state-channel",
|
32
|
+
# "coinbase-ventures-portfolio",
|
33
|
+
# "three-arrows-capital-portfolio",
|
34
|
+
# "polychain-capital-portfolio",
|
35
|
+
# "binance-labs-portfolio",
|
36
|
+
# "blockchain-capital-portfolio",
|
37
|
+
# "boostvc-portfolio",
|
38
|
+
# "cms-holdings-portfolio",
|
39
|
+
# "dcg-portfolio",
|
40
|
+
# "dragonfly-capital-portfolio",
|
41
|
+
# "electric-capital-portfolio",
|
42
|
+
# "fabric-ventures-portfolio",
|
43
|
+
# "framework-ventures-portfolio",
|
44
|
+
# "galaxy-digital-portfolio",
|
45
|
+
# "huobi-capital-portfolio",
|
46
|
+
# "alameda-research-portfolio",
|
47
|
+
# "a16z-portfolio",
|
48
|
+
# "1confirmation-portfolio",
|
49
|
+
# "winklevoss-capital-portfolio",
|
50
|
+
# "usv-portfolio",
|
51
|
+
# "placeholder-ventures-portfolio",
|
52
|
+
# "pantera-capital-portfolio",
|
53
|
+
# "multicoin-capital-portfolio",
|
54
|
+
# "paradigm-portfolio"
|
55
|
+
# ],
|
56
|
+
# "cmcRank": 1,
|
57
|
+
# "marketPairCount": 9922,
|
58
|
+
# "circulatingSupply": 19256812.0,
|
59
|
+
# "selfReportedCirculatingSupply": 0,
|
60
|
+
# "totalSupply": 19256812.0,
|
61
|
+
# "maxSupply": 21000000.0,
|
62
|
+
# "isActive": 1,
|
63
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
64
|
+
# "dateAdded": "2013-04-28T00:00:00.000Z",
|
65
|
+
# "quotes": [
|
66
|
+
# {
|
67
|
+
# "name": "USD",
|
68
|
+
# "price": 17209.447088639048,
|
69
|
+
# "volume24h": 13652714044.770432,
|
70
|
+
# "marketCap": 331399087209.8695,
|
71
|
+
# "percentChange1h": -0.00692023,
|
72
|
+
# "percentChange24h": 1.50954046,
|
73
|
+
# "percentChange7d": 2.78181713,
|
74
|
+
# "lastUpdated": "2023-01-09T08:25:00.000Z",
|
75
|
+
# "percentChange30d": 0.30441134,
|
76
|
+
# "percentChange60d": 3.89490715,
|
77
|
+
# "percentChange90d": -9.99714982,
|
78
|
+
# "fullyDilluttedMarketCap": 361398388861.42,
|
79
|
+
# "marketCapByTotalSupply": 331399087209.8695,
|
80
|
+
# "dominance": 39.0828,
|
81
|
+
# "turnover": 0.0411972,
|
82
|
+
# "ytdPriceChangePercentage": 3.515
|
83
|
+
# }
|
84
|
+
# ],
|
85
|
+
# "isAudited": false
|
86
|
+
# }
|
87
|
+
# ...
|
88
|
+
# ],
|
89
|
+
# "totalCount": "8857"
|
90
|
+
# },
|
91
|
+
# "status": {
|
92
|
+
# "timestamp": "2023-01-08T15:33:30.271Z",
|
93
|
+
# "error_code": "0",
|
94
|
+
# "error_message": "SUCCESS",
|
95
|
+
# "elapsed": "2",
|
96
|
+
# "credit_count": 0
|
97
|
+
# }
|
98
|
+
# }
|
99
|
+
#
|
100
|
+
# 'data' - Results of your query returned as an object map.
|
101
|
+
# 'cryptoCurrencyList' - Array of cryptocurrency objects matching the list options.
|
102
|
+
# 'totalCount' - Total number of cryptocurrencies
|
103
|
+
# 'status' - Standardized status object for API calls.
|
104
|
+
#
|
105
|
+
# If you want to sort in ascending, just write parameter:
|
106
|
+
#
|
107
|
+
# list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'asc')
|
108
|
+
#
|
109
|
+
# or
|
110
|
+
#
|
111
|
+
# list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'desc')
|
112
|
+
#
|
113
|
+
# You can also adding sort by:
|
114
|
+
#
|
115
|
+
# list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
|
116
|
+
#
|
117
|
+
# Convert cryptocurrency to::
|
118
|
+
#
|
119
|
+
# list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, convert: 'USD,BTC,ETH')
|
120
|
+
#
|
121
|
+
#
|
122
|
+
# @return [String]
|
123
|
+
# @param [Integer] start Optionally offset the start (1-based index) of the paginated list of items to return.
|
124
|
+
# @param [Integer] limit Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
|
125
|
+
# @param [String] sort_by 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")
|
126
|
+
# @param [String] sort_type The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
|
127
|
+
# @param [String] convert 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'
|
128
|
+
# @param [String] crypto_type The type of cryptocurrency to include. ('all', 'coins', 'tokens')
|
129
|
+
# @param [String] tag_type The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
|
130
|
+
# @param [TrueClass, FalseClass] audited Show audited 'true' or not 'false'
|
131
|
+
# @param [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.
|
132
|
+
# @param [String] tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
133
|
+
# @param [String] volume24h_range Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
|
134
|
+
# @param [String] percent_change24h_range Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
|
135
|
+
# @param [String] circulating_supply_range Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
136
|
+
# @param [String] price_range Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
137
|
+
# @param [String] market_cap_range Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
138
|
+
def get_list(start: 1,
|
139
|
+
limit: 100,
|
140
|
+
sort_by: 'market_cap',
|
141
|
+
sort_type: 'desc',
|
142
|
+
convert: 'USD',
|
143
|
+
crypto_type: 'all',
|
144
|
+
tag_type: 'all',
|
145
|
+
audited: false,
|
146
|
+
aux: nil,
|
147
|
+
tags: nil,
|
148
|
+
volume24h_range: nil,
|
149
|
+
percent_change24h_range: nil,
|
150
|
+
circulating_supply_range: nil,
|
151
|
+
price_range: nil,
|
152
|
+
market_cap_range: nil)
|
153
|
+
options = {
|
154
|
+
start: start, # Integer
|
155
|
+
limit: limit, # Integer
|
156
|
+
sortBy: sort_by, # String
|
157
|
+
sortType: sort_type, # String
|
158
|
+
convert: convert, # String
|
159
|
+
cryptoType: crypto_type, # String
|
160
|
+
tagType: tag_type, # String
|
161
|
+
audited: audited, # Boolean
|
162
|
+
aux: aux, # String
|
163
|
+
tags: tags, # String
|
164
|
+
volume24hRange: volume24h_range, # String
|
165
|
+
percentChange24hRange: percent_change24h_range, # String
|
166
|
+
circulatingSupplyRange: circulating_supply_range, # String
|
167
|
+
priceRange: price_range, # String
|
168
|
+
marketCapRange: market_cap_range # String
|
169
|
+
}
|
170
|
+
|
171
|
+
uri = Helper.generate_uri_for_data(URL_API, options)
|
172
|
+
Helper.request_to_read_data(uri)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -1,6 +1,22 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
require 'net/http'
|
5
|
-
require 'openssl'
|
6
|
-
require 'json'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'openssl'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
module CoinmarketcapFree
|
9
|
+
# Helper module for CoinmarketcapFree
|
10
|
+
module Helper
|
11
|
+
class << self
|
12
|
+
def request_to_read_data(uri_string)
|
13
|
+
uri = URI(uri_string)
|
14
|
+
Net::HTTP.get(uri)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_uri_for_data(url, data)
|
18
|
+
"#{url}?#{data.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CoinmarketcapFree
|
4
|
+
# Get static image of a coin from coinmarketcap.com
|
5
|
+
module Icons
|
6
|
+
class << self
|
7
|
+
# Get coin logo URI
|
8
|
+
#
|
9
|
+
# logo = CoinmarketcapFree.img_coin(1, 64)
|
10
|
+
#
|
11
|
+
# Result:
|
12
|
+
# "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
13
|
+
#
|
14
|
+
# @param [Integer] id_coin Identify coin. For example, bitcoin has 1
|
15
|
+
# @param [Integer] size Choose one size: 64, 128, 200
|
16
|
+
# @return [String] Return URI from coinmarketcap
|
17
|
+
def get_coin_logo_uri(id_coin, size)
|
18
|
+
size_x_size = case size
|
19
|
+
when 64, 128, 200
|
20
|
+
"#{size}x#{size}"
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Can't find this value: #{size}"
|
23
|
+
end
|
24
|
+
"https://s2.coinmarketcap.com/static/img/coins/#{size_x_size}/#{id_coin}.png"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CoinmarketcapFree
|
4
|
-
VERSION =
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CoinmarketcapFree
|
4
|
+
VERSION = '0.1.5'
|
5
|
+
end
|
data/lib/coinmarketcap_free.rb
CHANGED
@@ -1,216 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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, 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::
|
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
|
172
|
-
# @return [String, nil]
|
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 = {})
|
189
|
-
@@cryptocurrencies.instance_variables.each do |var_name|
|
190
|
-
value = options[var_name.to_s.delete('@').to_sym]
|
191
|
-
@@cryptocurrencies.instance_variable_set(var_name, value) unless value.nil?
|
192
|
-
end
|
193
|
-
|
194
|
-
@@cryptocurrencies.update ? @@cryptocurrencies.get_data : nil
|
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
|
215
|
-
end
|
216
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'coinmarketcap_free/coin_history'
|
4
|
+
require_relative 'coinmarketcap_free/coins'
|
5
|
+
require_relative 'coinmarketcap_free/icons'
|
6
|
+
require_relative 'coinmarketcap_free/version'
|
7
|
+
|
8
|
+
# Get data from Coinmarketcap API without requiring an API key.
|
9
|
+
module CoinmarketcapFree
|
10
|
+
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.5
|
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-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cryptocurrency information from the Coinmarketcap site without a key.
|
14
14
|
email:
|
@@ -17,20 +17,16 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- ".idea/.gitignore"
|
21
|
-
- ".idea/coinmarketcap_free.iml"
|
22
|
-
- ".idea/modules.xml"
|
23
|
-
- ".idea/vcs.xml"
|
24
20
|
- Gemfile
|
25
21
|
- Gemfile.lock
|
26
22
|
- LICENSE.txt
|
27
23
|
- README.md
|
28
24
|
- Rakefile
|
29
25
|
- lib/coinmarketcap_free.rb
|
30
|
-
- lib/coinmarketcap_free/
|
31
|
-
- lib/coinmarketcap_free/
|
32
|
-
- lib/coinmarketcap_free/cryptocurrencies.rb
|
26
|
+
- lib/coinmarketcap_free/coin_history.rb
|
27
|
+
- lib/coinmarketcap_free/coins.rb
|
33
28
|
- lib/coinmarketcap_free/helper.rb
|
29
|
+
- lib/coinmarketcap_free/icons.rb
|
34
30
|
- lib/coinmarketcap_free/version.rb
|
35
31
|
homepage:
|
36
32
|
licenses:
|