coincap 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/coincap.gemspec +36 -0
- data/lib/coincap/assets_price.rb +10 -15
- data/lib/coincap/exchanges.rb +2 -2
- data/lib/coincap/helper.rb +10 -12
- data/lib/coincap/markets.rb +20 -23
- data/lib/coincap/rates.rb +2 -2
- data/lib/coincap/version.rb +1 -1
- data/lib/coincap.rb +1 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 769b5aae59da08d6280a6982da0ca953443cd35b9652c94b5a1120d365563416
|
4
|
+
data.tar.gz: 7fb79111622a4237e07696889c7fa5c70f68e8c1a495426bb7c665b72120abfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a6b8b0c5773cdc3784a3fa353e3054be921e2e8d44a8057d52d06b6a2291c666fbfed5b2d7fc32246db1751ed9bc3d8828d32e098e1b83412b9f4e02d936e5e
|
7
|
+
data.tar.gz: a54d75fa5f9f0a1c9d1332bf99f07ec025c61d9516342296dfce90785c157a138007058d48c5cf328dd8f4daea69b18bd503a215e0bce396acb96423421a8b1e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@ CoinCap is a useful tool for real-time pricing and market activity for over 1,00
|
|
4
4
|
If you want to add 'api key' or change 'accept encoding', just call the 'configure' method.
|
5
5
|
|
6
6
|
No API Key: 200 requests per minute
|
7
|
+
|
7
8
|
API Key: 500 requests per minute
|
8
9
|
|
9
10
|
Generate API KEY [here](https://coincap.io/api-key).
|
@@ -211,4 +212,4 @@ data = Coincap::Markets.list
|
|
211
212
|
],
|
212
213
|
"timestamp": 1533581173350
|
213
214
|
}
|
214
|
-
```
|
215
|
+
```
|
data/coincap.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/coincap/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'coincap'
|
7
|
+
spec.version = Coincap::VERSION
|
8
|
+
spec.authors = ['cosmic-1']
|
9
|
+
spec.email = ['crossdoh@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
|
12
|
+
spec.description = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
|
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/coincap'
|
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
|
+
end
|
data/lib/coincap/assets_price.rb
CHANGED
@@ -45,20 +45,13 @@ module Coincap
|
|
45
45
|
# "timestamp": 1533581088278
|
46
46
|
# }
|
47
47
|
#
|
48
|
-
# @param [
|
49
|
-
# @
|
50
|
-
# @
|
51
|
-
# @
|
52
|
-
# @
|
53
|
-
|
54
|
-
|
55
|
-
quries = {
|
56
|
-
'search': options[:search],
|
57
|
-
'ids': options[:ids],
|
58
|
-
'limit': options[:limit],
|
59
|
-
'offset': options[:offset]
|
60
|
-
}
|
61
|
-
Helper.request_to_read_data(URI_API, **quries)
|
48
|
+
# @param [String] search (nil) Search by asset id (bitcoin) or symbol (BTC)
|
49
|
+
# @param [String] ids (nil) Query with multiple ids=bitcoin,ethereum,monero
|
50
|
+
# @param [Integer] limit (nil) Max limit of 2000
|
51
|
+
# @param [Integer] offset (nil) Offset
|
52
|
+
# @return [String]
|
53
|
+
def self.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil)
|
54
|
+
Helper.request_to_read_data(URI_API, search: search, ids: ids, limit: limit, offset: offset)
|
62
55
|
end
|
63
56
|
|
64
57
|
# Get single cryptocurrency
|
@@ -81,7 +74,7 @@ module Coincap
|
|
81
74
|
# }
|
82
75
|
#
|
83
76
|
# @param [String] asset_id Asset id, for example, bitcoin
|
84
|
-
# @return [
|
77
|
+
# @return [String]
|
85
78
|
def self.cryptocurrency(asset_id)
|
86
79
|
Helper.request_to_read_data("#{URI_API}/#{asset_id}")
|
87
80
|
end
|
@@ -101,6 +94,7 @@ module Coincap
|
|
101
94
|
#
|
102
95
|
# @param [String] asset_id Asset id, for example, bitcoin
|
103
96
|
# @param [Symbol] interval Select one from the list m1,m5,m15,m30,h1,h2,h6,h12,d1, for example, m1 or write a symbol, for example, :one_minute
|
97
|
+
# @return [String]
|
104
98
|
def self.cryptocurrency_history(asset_id, interval)
|
105
99
|
Helper.request_to_read_data("#{URI_API}/#{asset_id}/history",
|
106
100
|
interval: interval.is_a?(Symbol) ? TIME_INTERVAL[interval] : interval)
|
@@ -128,6 +122,7 @@ module Coincap
|
|
128
122
|
# @param [String] asset_id Asset id, for example, bitcoin
|
129
123
|
# @param [Integer] limit Max limit of 2000
|
130
124
|
# @param [Integer] offset Offset
|
125
|
+
# @return [String]
|
131
126
|
def self.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil)
|
132
127
|
Helper.request_to_read_data("#{URI_API}/#{asset_id}/markets", limit: limit, offset: offset)
|
133
128
|
end
|
data/lib/coincap/exchanges.rb
CHANGED
@@ -33,7 +33,7 @@ module Coincap
|
|
33
33
|
# "timestamp": 1536605835421
|
34
34
|
# }
|
35
35
|
#
|
36
|
-
# @return [
|
36
|
+
# @return [String]
|
37
37
|
def self.list
|
38
38
|
Helper.request_to_read_data(URI_API)
|
39
39
|
end
|
@@ -56,7 +56,7 @@ module Coincap
|
|
56
56
|
# }
|
57
57
|
#
|
58
58
|
# @param exchange_id [String]
|
59
|
-
# @return [
|
59
|
+
# @return [String]
|
60
60
|
def self.single(exchange_id)
|
61
61
|
Helper.request_to_read_data("#{URI_API}/#{exchange_id}")
|
62
62
|
end
|
data/lib/coincap/helper.rb
CHANGED
@@ -8,26 +8,24 @@ require 'openssl'
|
|
8
8
|
module Coincap
|
9
9
|
# Helper module
|
10
10
|
module Helper
|
11
|
-
def self.request_to_read_data(uri_string, **queries_hash)
|
12
|
-
uri = convert_hash_to_uri(uri_string, **queries_hash)
|
13
|
-
|
14
|
-
data_str = http_get(uri)
|
15
|
-
|
16
|
-
JSON.parse(data_str)
|
17
|
-
end
|
18
|
-
|
19
11
|
class << self
|
12
|
+
# Request to read data
|
13
|
+
# @param uri_string [String] string of the uri
|
14
|
+
# @param queries_hash [Hash] queries hash for the request
|
15
|
+
# @return [String]
|
16
|
+
def request_to_read_data(uri_string, **queries_hash)
|
17
|
+
http_get convert_hash_to_uri(uri_string, **queries_hash)
|
18
|
+
end
|
19
|
+
|
20
20
|
private
|
21
21
|
|
22
22
|
def http_get(uri)
|
23
23
|
config = Coincap.instance_variable_get(:@config)
|
24
24
|
|
25
25
|
headers = {
|
26
|
-
'Accept-Encoding': config.accept_encoding,
|
26
|
+
'Accept-Encoding': config.accept_encoding.nil? ? nil : config.accept_encoding,
|
27
27
|
'Authorization': config.api_key.nil? ? nil : "Bearer #{config.api_key}"
|
28
|
-
}
|
29
|
-
|
30
|
-
headers.compact!
|
28
|
+
}.compact
|
31
29
|
|
32
30
|
Net::HTTP.get(uri, headers)
|
33
31
|
end
|
data/lib/coincap/markets.rb
CHANGED
@@ -35,30 +35,27 @@ module Coincap
|
|
35
35
|
# "timestamp": 1533581173350
|
36
36
|
# }
|
37
37
|
#
|
38
|
-
# @param
|
39
|
-
# @
|
40
|
-
# @
|
41
|
-
# @
|
42
|
-
# @
|
43
|
-
# @
|
44
|
-
# @
|
45
|
-
# @
|
46
|
-
# @
|
47
|
-
# @
|
48
|
-
# @return [Hash]
|
38
|
+
# @param [String] exchange_id (nil) Search by exchange id (e.g. 'binance')
|
39
|
+
# @param [String] base_symbol (nil) Returns all containing the base symbol
|
40
|
+
# @param [String] quote_symbol (nil) Returns all containing the quote symbol
|
41
|
+
# @param [String] base_id (nil) Returns all containing the base id
|
42
|
+
# @param [String] quote_id (nil) Returns all containing the quote id
|
43
|
+
# @param [String] asset_symbol (nil) Returns all assets containing symbol (base and quote)
|
44
|
+
# @param [String] asset_id (nil) Returns all assets containing id (base and quote)
|
45
|
+
# @param [Integer] limit (nil) Max limit of 2000
|
46
|
+
# @param [Integer] offset (nil) The number of results to skip
|
47
|
+
# @return [String]
|
49
48
|
def self.list(**options)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
Helper.request_to_read_data(URI_API, **queries)
|
49
|
+
Helper.request_to_read_data(URI_API,
|
50
|
+
'exchangeId': options[:exchange_id],
|
51
|
+
'baseSymbol': options[:base_symbol],
|
52
|
+
'quoteSymbol': options[:quote_symbol],
|
53
|
+
'baseId': options[:base_id],
|
54
|
+
'quoteId': options[:quote_id],
|
55
|
+
'assetSymbol': options[:asset_symbol],
|
56
|
+
'assetId': options[:asset_id],
|
57
|
+
'limit': options[:limit],
|
58
|
+
'offset': options[:offset])
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
data/lib/coincap/rates.rb
CHANGED
@@ -26,7 +26,7 @@ module Coincap
|
|
26
26
|
# "timestamp": 1536347807471
|
27
27
|
# }
|
28
28
|
#
|
29
|
-
# @return [
|
29
|
+
# @return [String]
|
30
30
|
def self.list
|
31
31
|
Helper.request_to_read_data(URI_API)
|
32
32
|
end
|
@@ -45,7 +45,7 @@ module Coincap
|
|
45
45
|
# }
|
46
46
|
#
|
47
47
|
# @param asset_id [String] The asset id (bitcoin)
|
48
|
-
# @return [
|
48
|
+
# @return [String]
|
49
49
|
def self.single(asset_id)
|
50
50
|
Helper.request_to_read_data("#{URI_API}/#{asset_id}")
|
51
51
|
end
|
data/lib/coincap/version.rb
CHANGED
data/lib/coincap.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coincap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cosmic-1
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: CoinCap is a useful tool for real-time pricing and market activity for
|
14
14
|
over 1,000 cryptocurrencies.
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
+
- coincap.gemspec
|
26
27
|
- lib/coincap.rb
|
27
28
|
- lib/coincap/assets_price.rb
|
28
29
|
- lib/coincap/exchanges.rb
|