cryptocompare 0.10.0 → 0.15.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.
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{A Ruby gem for communicating with the CryptoCompare API}
14
14
  spec.homepage = "https://github.com/alexanderdavidpan/cryptocompare"
15
15
  spec.license = "MIT"
16
-
17
- spec.required_ruby_version = '>= 2.0.0'
16
+
17
+ spec.required_ruby_version = '>= 2.3.0'
18
18
 
19
19
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
20
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.12"
33
- spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "bundler", "~> 2.1.0"
33
+ spec.add_development_dependency "rake", ">= 12.3.3"
34
34
  spec.add_development_dependency "minitest", "~> 5.0"
35
35
  spec.add_development_dependency "vcr"
36
36
  spec.add_development_dependency "webmock"
@@ -1,8 +1,11 @@
1
1
  require_relative "cryptocompare/version"
2
+ require_relative "cryptocompare/coin_list"
2
3
  require_relative "cryptocompare/coin_snapshot"
4
+ require_relative "cryptocompare/exchanges"
3
5
  require_relative "cryptocompare/histo_day"
4
6
  require_relative "cryptocompare/histo_hour"
5
7
  require_relative "cryptocompare/histo_minute"
8
+ require_relative "cryptocompare/news"
6
9
  require_relative "cryptocompare/price"
7
10
  require_relative "cryptocompare/price_historical"
8
11
  require_relative "cryptocompare/helpers/query_param_helper"
@@ -0,0 +1,76 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Cryptocompare
5
+ module CoinList
6
+ API_URL = 'https://min-api.cryptocompare.com/data/all/coinlist'
7
+
8
+ # Get general info for all the coins available on Cryptocompare's API.
9
+ #
10
+ # ==== Returns
11
+ #
12
+ # [Hash] Hash with data Data key which is a hash where coin symbols are the
13
+ # keys and each coin object cointains metadata about each coin.
14
+ #
15
+ # ==== Example
16
+ #
17
+ # Get all coins supported by Cryptocompare's API.
18
+ #
19
+ # Cryptocompare::CoinList.all
20
+ #
21
+ # Sample response
22
+ #
23
+ # {
24
+ # "Response" => "Success",
25
+ # "Message" => "Coin list succesfully returned!",
26
+ # "BaseImageUrl" => "https://www.cryptocompare.com",
27
+ # "BaseLinkUrl" => "https://www.cryptocompare.com",
28
+ # "DefaultWatchlist" => {
29
+ # "CoinIs" => "1182,7605,5038,24854,3807,3808,202330,5324,5031,20131",
30
+ # "Sponsored" => ""
31
+ # },
32
+ # "Data" => {
33
+ # "BTC" => {
34
+ # "Id" => "1182",
35
+ # "Url" => "/coins/btc/overview",
36
+ # "ImageUrl" => "/media/19633/btc.png",
37
+ # "Name" => "BTC",
38
+ # "Symbol" => "BTC",
39
+ # "CoinName" => "Bitcoin",
40
+ # "FullName" => "Bitcoin (BTC)",
41
+ # "Algorithm" => "SHA256",
42
+ # "ProofType" => "PoW",
43
+ # "FullyPremined" => "0",
44
+ # "TotalCoinSupply" => "21000000",
45
+ # "PreMinedValue" => "N/A",
46
+ # "TotalCoinsFreeFloat" => "N/A",
47
+ # "SortOrder" => "1",
48
+ # "Sponsored" => false
49
+ # },
50
+ # "ETH" => {
51
+ # "Id" => "7605",
52
+ # "Url" => "/coins/eth/overview",
53
+ # "ImageUrl" => "/media/20646/eth_logo.png",
54
+ # "Name" => "ETH",
55
+ # "Symbol" => "ETH",
56
+ # "CoinName" => "Ethereum ",
57
+ # "FullName" => "Ethereum (ETH)",
58
+ # "Algorithm" => "Ethash",
59
+ # "ProofType" => "PoW",
60
+ # "FullyPremined" => "0",
61
+ # "TotalCoinSupply" => "0",
62
+ # "PreMinedValue" => "N/A",
63
+ # "TotalCoinsFreeFloat" => "N/A",
64
+ # "SortOrder" => "2",
65
+ # "Sponsored" => false
66
+ # },
67
+ # ...
68
+ # },
69
+ # "Type" => 100
70
+ # }
71
+ def self.all
72
+ api_resp = Faraday.get(API_URL)
73
+ JSON.parse(api_resp.body)
74
+ end
75
+ end
76
+ end
@@ -27,51 +27,51 @@ module Cryptocompare
27
27
  # Sample response
28
28
  #
29
29
  # {
30
- # "Response":"Success",
31
- # "Message":"Coin snapshot succesfully returned",
32
- # "Type":100,
33
- # "Data":{
34
- # "Algorithm":"SHA256",
35
- # "ProofType":"PoW",
36
- # "BlockNumber":378345,
37
- # "NetHashesPerSecond":465548431.66333866,
38
- # "TotalCoinsMined":14707625.0,
39
- # "BlockReward":25.0,
40
- # "AggregatedData":{
41
- # "TYPE":"5",
42
- # "MARKET":"CCCAGG",
43
- # "FROMSYMBOL":"BTC",
44
- # "TOSYMBOL":"USD",
45
- # "FLAGS":"4",
46
- # "PRICE":"245.41",
47
- # "LASTUPDATE":"1444520460",
48
- # "LASTVOLUME":"0.0086",
49
- # "LASTVOLUMETO":"2.110268",
50
- # "LASTTRADEID":"1444520460357",
51
- # "VOLUME24HOUR":"49591.48108707269",
52
- # "VOLUME24HOURTO":"12139110.189163648",
53
- # "OPEN24HOUR":"244.41",
54
- # "HIGH24HOUR":"258.37",
55
- # "LOW24HOUR":"239.01000004",
56
- # "LASTMARKET":"Huobi"
30
+ # "Response" => "Success",
31
+ # "Message" => "Coin snapshot succesfully returned",
32
+ # "Type" => 100,
33
+ # "Data" => {
34
+ # "Algorithm" => "SHA256",
35
+ # "ProofType" => "PoW",
36
+ # "BlockNumber" => 378345,
37
+ # "NetHashesPerSecond" => 465548431.66333866,
38
+ # "TotalCoinsMined" => 14707625.0,
39
+ # "BlockReward" => 25.0,
40
+ # "AggregatedData" => {
41
+ # "TYPE" => "5",
42
+ # "MARKET" => "CCCAGG",
43
+ # "FROMSYMBOL" => "BTC",
44
+ # "TOSYMBOL" => "USD",
45
+ # "FLAGS" => "4",
46
+ # "PRICE" => "245.41",
47
+ # "LASTUPDATE" => "1444520460",
48
+ # "LASTVOLUME" => "0.0086",
49
+ # "LASTVOLUMETO" => "2.110268",
50
+ # "LASTTRADEID" => "1444520460357",
51
+ # "VOLUME24HOUR" => "49591.48108707269",
52
+ # "VOLUME24HOURTO" => "12139110.189163648",
53
+ # "OPEN24HOUR" => "244.41",
54
+ # "HIGH24HOUR" => "258.37",
55
+ # "LOW24HOUR" => "239.01000004",
56
+ # "LASTMARKET" => "Huobi"
57
57
  # },
58
- # "Exchanges":[
58
+ # "Exchanges" => [
59
59
  # {
60
- # "TYPE":"2",
61
- # "MARKET":"LakeBTC",
62
- # "FROMSYMBOL":"BTC",
63
- # "TOSYMBOL":"USD",
64
- # "FLAGS":"2",
65
- # "PRICE":"244.37",
66
- # "LASTUPDATE":"1444513131",
67
- # "LASTVOLUME":"0.03",
68
- # "LASTVOLUMETO":"7.3311",
69
- # "LASTTRADEID":"1444513131",
70
- # "VOLUME24HOUR":"3599.0560000000005",
71
- # "VOLUME24HOURTO":"879237.6299349999",
72
- # "OPEN24HOUR":"243.83",
73
- # "HIGH24HOUR":"245.23",
74
- # "LOW24HOUR":"242.68"
60
+ # "TYPE" => "2",
61
+ # "MARKET" => "LakeBTC",
62
+ # "FROMSYMBOL" => "BTC",
63
+ # "TOSYMBOL" => "USD",
64
+ # "FLAGS" => "2",
65
+ # "PRICE" => "244.37",
66
+ # "LASTUPDATE" => "1444513131",
67
+ # "LASTVOLUME" => "0.03",
68
+ # "LASTVOLUMETO" => "7.3311",
69
+ # "LASTTRADEID" => "1444513131",
70
+ # "VOLUME24HOUR" => "3599.0560000000005",
71
+ # "VOLUME24HOURTO" => "879237.6299349999",
72
+ # "OPEN24HOUR" => "243.83",
73
+ # "HIGH24HOUR" => "245.23",
74
+ # "LOW24HOUR" => "242.68"
75
75
  # },
76
76
  # ....
77
77
  # ]
@@ -0,0 +1,53 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Cryptocompare
5
+ module Exchanges
6
+ API_URL = 'https://min-api.cryptocompare.com/data/all/exchanges'
7
+
8
+ # Get exchange data, such as cryptocurrencies that each exchange offers, and
9
+ # the supported conversion cryptocurrencies.
10
+ #
11
+ # ==== Returns
12
+ #
13
+ # [Hash] Hash of exchanges, cryptocurrencies that each exchange offers, and
14
+ # the supported conversion cryptocurrencies.
15
+ #
16
+ # ==== Example
17
+ #
18
+ # Get info for all exchanges.
19
+ #
20
+ # Cryptocompare::Exchanges.all
21
+ #
22
+ # Sample response
23
+ #
24
+ # {
25
+ # "Coinbase" => {
26
+ # "LTC" => [
27
+ # "BTC",
28
+ # "USD",
29
+ # "EUR"
30
+ # ],
31
+ # "ETH" => [
32
+ # "BTC",
33
+ # "USD",
34
+ # "EUR"
35
+ # ],
36
+ # "BTC" => [
37
+ # "USD",
38
+ # "GBP",
39
+ # "EUR",
40
+ # "CAD"
41
+ # ],
42
+ # "BCH" => [
43
+ # "USD"
44
+ # ]
45
+ # },
46
+ # ...
47
+ # }
48
+ def self.all
49
+ api_resp = Faraday.get(API_URL)
50
+ JSON.parse(api_resp.body)
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,4 @@
1
1
  require 'yaml'
2
- require_relative 'exchange_name_helper'
3
2
 
4
3
  # Helper module for setting query params.
5
4
  module Cryptocompare
@@ -14,7 +13,6 @@ module Cryptocompare
14
13
  # Helper method to parse parameters and build query parameters
15
14
  def self.to_query(opts)
16
15
  opts.collect do |key, value|
17
- value = ExchangeNameHelper.set_exchange(value) if key == 'e'
18
16
  "#{QUERY_PARAM_MAPPING[key]}=#{value}"
19
17
  end.sort * '&'
20
18
  end
@@ -37,36 +37,36 @@ module Cryptocompare
37
37
  # Sample response
38
38
  #
39
39
  # {
40
- # Response: "Success",
41
- # Type: 100,
42
- # Aggregated: false,
43
- # Data: [
40
+ # "Response" => "Success",
41
+ # "Type" => 100,
42
+ # "Aggregated" => false,
43
+ # "Data" => [
44
44
  # {
45
- # time: 1500854400,
46
- # close: 2763.42,
47
- # high: 2798.89,
48
- # low: 2715.69,
49
- # open: 2756.61,
50
- # volumefrom: 83009.25,
51
- # volumeto: 229047365.02
45
+ # "time" => 1500854400,
46
+ # "close" => 2763.42,
47
+ # "high" => 2798.89,
48
+ # "low" => 2715.69,
49
+ # "open" => 2756.61,
50
+ # "volumefrom" => 83009.25,
51
+ # "volumeto" => 229047365.02
52
52
  # },
53
53
  # {
54
- # time: 1500940800,
55
- # close: 2582.58,
56
- # high: 2779.08,
57
- # low: 2472.62,
58
- # open: 2763.42,
59
- # volumefrom: 205883.15,
60
- # volumeto: 534765380.75
54
+ # "time" => 1500940800,
55
+ # "close" => 2582.58,
56
+ # "high" => 2779.08,
57
+ # "low" => 2472.62,
58
+ # "open" => 2763.42,
59
+ # "volumefrom" => 205883.15,
60
+ # "volumeto" => 534765380.75
61
61
  # },
62
62
  # ...
63
63
  # ],
64
- # TimeTo: 1503446400,
65
- # TimeFrom: 1500854400,
66
- # FirstValueInArray: true,
67
- # ConversionType: {
68
- # type: "direct",
69
- # conversionSymbol: ""
64
+ # "TimeTo" => 1503446400,
65
+ # "TimeFrom" => 1500854400,
66
+ # "FirstValueInArray" => true,
67
+ # "ConversionType" => {
68
+ # "type" => "direct",
69
+ # "conversionSymbol" => ""
70
70
  # }
71
71
  # }
72
72
  def self.find(from_sym, to_sym, opts = {})
@@ -36,36 +36,36 @@ module Cryptocompare
36
36
  # Sample response
37
37
  #
38
38
  # {
39
- # Response: "Success",
40
- # Type: 100,
41
- # Aggregated: false,
42
- # Data: [
39
+ # "Response" => "Success",
40
+ # "Type" => 100,
41
+ # "Aggregated" => false,
42
+ # "Data" => [
43
43
  # {
44
- # time: 1502643600,
45
- # close: 3998.47,
46
- # high: 4069.8,
47
- # low: 3982.5,
48
- # open: 4059.28,
49
- # volumefrom: 5087.23,
50
- # volumeto: 20453919.02
44
+ # "time" => 1502643600,
45
+ # "close" => 3998.47,
46
+ # "high" => 4069.8,
47
+ # "low" => 3982.5,
48
+ # "open" => 4059.28,
49
+ # "volumefrom" => 5087.23,
50
+ # "volumeto" => 20453919.02
51
51
  # },
52
52
  # {
53
- # time: 1502647200,
54
- # close: 4061.5,
55
- # high: 4074.57,
56
- # low: 3998.47,
57
- # open: 3998.47,
58
- # volumefrom: 3839.78,
59
- # volumeto: 15606476.19
53
+ # "time" => 1502647200,
54
+ # "close" => 4061.5,
55
+ # "high" => 4074.57,
56
+ # "low" => 3998.47,
57
+ # "open" => 3998.47,
58
+ # "volumefrom" => 3839.78,
59
+ # "volumeto" => 15606476.19
60
60
  # },
61
61
  # ...
62
62
  # ],
63
- # TimeTo: 1503248400,
64
- # TimeFrom: 1502643600,
65
- # FirstValueInArray: true,
66
- # ConversionType: {
67
- # type: "direct",
68
- # conversionSymbol: ""
63
+ # "TimeTo" => 1503248400,
64
+ # "TimeFrom" => 1502643600,
65
+ # "FirstValueInArray" => true,
66
+ # "ConversionType" => {
67
+ # "type" => "direct",
68
+ # "conversionSymbol" => ""
69
69
  # }
70
70
  # }
71
71
  def self.find(from_sym, to_sym, opts = {})
@@ -39,36 +39,36 @@ module Cryptocompare
39
39
  # Sample response
40
40
  #
41
41
  # {
42
- # Response: "Success",
43
- # Type: 100,
44
- # Aggregated: true,
45
- # Data: [
42
+ # "Response" => "Success",
43
+ # "Type" => 100,
44
+ # "Aggregated" => true,
45
+ # "Data" => [
46
46
  # {
47
- # time: 1502259120,
48
- # close: 3396.44,
49
- # high: 3397.63,
50
- # low: 3396.34,
51
- # open: 3397.39,
52
- # volumefrom: 98.2,
53
- # volumeto: 335485
47
+ # "time" => 1502259120,
48
+ # "close" => 3396.44,
49
+ # "high" => 3397.63,
50
+ # "low" => 3396.34,
51
+ # "open" => 3397.39,
52
+ # "volumefrom" => 98.2,
53
+ # "volumeto" => 335485
54
54
  # },
55
55
  # {
56
- # time: 1502259300,
57
- # close: 3396.86,
58
- # high: 3396.94,
59
- # low: 3396.44,
60
- # open: 3396.44,
61
- # volumefrom: 16.581031,
62
- # volumeto: 56637.869999999995
56
+ # "time" => 1502259300,
57
+ # "close" => 3396.86,
58
+ # "high" => 3396.94,
59
+ # "low" => 3396.44,
60
+ # "open" => 3396.44,
61
+ # "volumefrom" => 16.581031,
62
+ # "volumeto" => 56637.869999999995
63
63
  # },
64
64
  # ...
65
65
  # ],
66
- # TimeTo: 1502259360,
67
- # TimeFrom: 1502259120,
68
- # FirstValueInArray: true,
69
- # ConversionType: {
70
- # type: "direct",
71
- # conversionSymbol: ""
66
+ # "TimeTo" => 1502259360,
67
+ # "TimeFrom" => 1502259120,
68
+ # "FirstValueInArray" => true,
69
+ # "ConversionType" => {
70
+ # "type" => "direct",
71
+ # "conversionSymbol" => ""
72
72
  # }
73
73
  # }
74
74
  def self.find(from_sym, to_sym, opts = {})