coinmarketcap-ruby-client 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 378c754280f2105451ade40e5c3f56a8ffe66dded187feb5948fdc7aa83b3ba7
4
- data.tar.gz: ab7bce01c3133499a282c777e4f049cbea1ad661699ca5ef2a26158fd44e670d
3
+ metadata.gz: c92b7dcc192e4c5124e62a64404cd9022047a2ef349face7b0231cefe95c9349
4
+ data.tar.gz: ce068a4e060eeaf614d3d2908009e04efc54268e6189c83e3a975ead1eb20b7e
5
5
  SHA512:
6
- metadata.gz: f8058075d308ecec683b1e95b9632411ea2ef7bfe1f0540cdd80a90aa019210505f7e405506e231cd567b5ddde475b54a47f8afb60f1975f1d5f81076f7b875c
7
- data.tar.gz: '079587b57b95e4b9d9bad537750b7859b18a3d79ed46d610aaf219fcdf280bd02f4f8446bacec97f384437d6cbd7cd7274f00ba6a184f68bfc09feda4ad36bab'
6
+ metadata.gz: ad8cdadeef43edf7aeca19f9f5ed2cba0cf95f7571acb8e62bb2c594c79ebe1a04b2f88942350e42466ed5233ccca416c08a3851f1d0623ffef880d7b13a7f39
7
+ data.tar.gz: 7fdc18918edec0df7c660315755bae5ae4ac7af49253c065bae9255780baa209534b4121bec1cd036666c893d4f7e8cc42dc13e9de1b1437332283b88f4f1154
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.6', '2.7', '3.0']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
+ - name: Run tests
25
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
- ### 1.0.1 (Next)
2
- * Contributions here
1
+ ### 1.1.1 (Next)
2
+
3
+ - your contributions here ...
4
+
5
+ ### 1.1.0 (2021/10/09)
6
+
7
+ - [#5](https://github.com/koffeefinance/coinmarketcap-ruby-client/pull/5): Added support to fetch metadata for a cryptocurrency via the /info endpoint - [@mathu97](https://github.com/mathu97).
8
+ - [#10](https://github.com/koffeefinance/coinmarketcap-ruby-client/pull/10): Added support to fetch latest listings - [@mathu97](https://github.com/mathu97).
3
9
 
4
10
  ### 1.0.0 (2021/10/05)
5
- * [#1](https://github.com/koffeefinance/coinmarketcap-ruby-client/pull/1): Added support to fetch the CoinMarketCap ID Map.
6
11
 
12
+ - [#1](https://github.com/koffeefinance/coinmarketcap-ruby-client/pull/1): Added support to fetch the CoinMarketCap ID Map - [@mathu97](https://github.com/mathu97).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coinmarketcap-ruby-client (1.0.0)
4
+ coinmarketcap-ruby-client (1.1.0)
5
5
  faraday (>= 1.8)
6
6
  faraday_middleware (>= 1.1)
7
7
  hashie
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # CoinMarketCap Ruby API Client
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/coinmarketcap-ruby-client.svg)](https://badge.fury.io/rb/coinmarketcap-ruby-client) ![Build Status](https://github.com/koffeefinance/coinmarketcap-ruby-client/actions/workflows/ruby.yml/badge.svg)
4
+
3
5
  A ruby API client for [CoinMarketCap](https://coinmarketcap.com/api/documentation/v1/)
4
6
 
5
7
  # Table of Contents
@@ -9,6 +11,8 @@ A ruby API client for [CoinMarketCap](https://coinmarketcap.com/api/documentatio
9
11
  - [Get an API Key](#get-an-api-token)
10
12
  - [Configure](#configure)
11
13
  - [Get CoinMarketCap ID Map](#get-coinmarketcap-id-map)
14
+ - [Get Cryptocurrency Metadata](#get-cryptocurrency-metadata)
15
+ - [Get Latest Listings](#get-latest-listings)
12
16
  - [Development](#development)
13
17
  - [Contributing](#contributing)
14
18
  - [License](#license)
@@ -71,7 +75,80 @@ platform.slug # 'ethereum'
71
75
  platform.token_address # '0xdac17f958d2ee523a2206206994597c13d831ec7'
72
76
  ```
73
77
 
74
- See [Cryptocurrency Map](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyMap) for detailed documentation.
78
+ See [CoinMarketCap ID Map](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyMap) for detailed documentation.
79
+
80
+ ### Get Cryptocurrency Metadata
81
+
82
+ Fetches static metadata available for one or more cryptocurrencies.
83
+
84
+ ```ruby
85
+ info = client.info(symbol: 'ETH')
86
+
87
+ metadata = info['ETH']
88
+ metadata.id # 1027
89
+ metadata.name # 'Ethereum'
90
+ metadata.symbol # 'ETH'
91
+ metadata.category # 'coin'
92
+ metadata.description # 'Ethereum (ETH) is a cryptocurrency . Users are able to generate ETH ...'
93
+ metadata.slug # 'ethereum'
94
+ metadata.logo # 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png'
95
+ metadata.notice # ''
96
+ metadata.tags # ['mineable', 'pow', 'smart-contracts', ...]
97
+ metadata.platform # nil
98
+
99
+ urls = metadata.urls
100
+ urls.website # ['https://www.ethereum.org/', 'https://en.wikipedia.org/wiki/Ethereum']
101
+ urls.twitter # ['https://twitter.com/ethereum']
102
+ urls.message_board # ['https://forum.ethereum.org/', 'https://ethresear.ch/']
103
+ urls.chat # ['https://gitter.im/orgs/ethereum/rooms']
104
+ urls.explorer # ['https://etherscan.io/', 'https://ethplorer.io/', 'https://blockchair.com/ethereum', ...]
105
+ urls.reddit # ['https://reddit.com/r/ethereum']
106
+ urls.technical_doc # ['https://github.com/ethereum/wiki/wiki/White-Paper']
107
+ urls.source_code # ['https://github.com/ethereum']
108
+ urls.announcement # ['https://bitcointalk.org/index.php?topic=428589.0']
109
+ ```
110
+
111
+ See [Cryptocurrency Metadata](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyInfo) for detailed documentation.
112
+
113
+ ### Get Latest Listings
114
+
115
+ Returns a paginated list of all active cryptocurrencies with latest market data.
116
+
117
+ ```ruby
118
+ listings = client.listings_latest
119
+ listing = listings.first
120
+
121
+ listing.id # 1
122
+ listing.name # 'Bitcoin'
123
+ listing.symbol # 'BTC'
124
+ listing.slug # 'bitcoin'
125
+ listing.num_market_pairs # 8527
126
+ listing.date_added # <Date: 2013-04-28 ((2456411j,0s,0n),+0s,2299161j)>
127
+ listing.tags # ['mineable', 'pow', 'sha-256', 'store-of-value', ...]
128
+ listing.max_supply # 21000000
129
+ listing.circulating_supply # 18837706
130
+ listing.total_supply # 18837706
131
+ listing.platform # nil
132
+ listing.cmc_rank # 1
133
+ listing.last_updated # <Date: 2021-10-08 ((2459496j,0s,0n),+0s,2299161j)>
134
+
135
+ quote_in_usd = listing.quote['USD']
136
+
137
+ quote_in_usd.price # 53853.84605722145
138
+ quote_in_usd.volume_24h # 35664606394.86121
139
+ quote_in_usd.percent_change_1h # -0.08049597
140
+ quote_in_usd.percent_change_24h # -1.93058
141
+ quote_in_usd.percent_change_7d # 23.57830268
142
+ quote_in_usd.percent_change_30d # 15.8506565
143
+ quote_in_usd.percent_change_60d # 24.08594399
144
+ quote_in_usd.percent_change_90d # 59.25745607
145
+ quote_in_usd.market_cap # 1014482918995.1969
146
+ quote_in_usd.market_cap_dominance # 44.5955
147
+ quote_in_usd.fully_diluted_market_cap # 1130930767201.65
148
+ quote_in_usd.last_updated # <Date: 2021-10-08 ((2459496j,0s,0n),+0s,2299161j)>
149
+ ```
150
+
151
+ See [Listings Latest](https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsLatest) for detailed documentation.
75
152
 
76
153
  ## Development
77
154
 
@@ -2,9 +2,21 @@ module CoinMarketCap
2
2
  module Endpoints
3
3
  module Cryptocurrency
4
4
  def map(options = {})
5
- response = get('cryptocurrency/map', {}.merge(options))
5
+ response = get('cryptocurrency/map', options)
6
6
  response['data'].map { |row| CoinMarketCap::Resources::Cryptocurrency.new(row) }
7
7
  end
8
+
9
+ def info(options = {})
10
+ response = get('cryptocurrency/info', options)
11
+ response['data'].map do |key, value|
12
+ [key, CoinMarketCap::Resources::Metadata.new(value)]
13
+ end.to_h
14
+ end
15
+
16
+ def listings_latest(options = {})
17
+ response = get('cryptocurrency/listings/latest', options)
18
+ response['data'].map { |row| CoinMarketCap::Resources::Listing.new(row) }
19
+ end
8
20
  end
9
21
  end
10
22
  end
@@ -0,0 +1,27 @@
1
+ module CoinMarketCap
2
+ module Resources
3
+ class Listing < Resource
4
+ property 'id'
5
+ property 'name'
6
+ property 'symbol'
7
+ property 'slug'
8
+ property 'cmc_rank'
9
+ property 'num_market_pairs'
10
+ property 'circulating_supply'
11
+ property 'total_supply'
12
+ property 'market_cap_by_total_supply'
13
+ property 'max_supply'
14
+ property 'last_updated', transform_with: ->(v) { iso8601_date(v) }
15
+ property 'date_added', transform_with: ->(v) { iso8601_date(v) }
16
+ property 'tags'
17
+ property 'platform', transform_with: lambda { |v|
18
+ CoinMarketCap::Resources::Platform.new(v) unless v.nil?
19
+ }
20
+ property 'quote', transform_with: lambda { |v|
21
+ v.map do |key, value|
22
+ [key, CoinMarketCap::Resources::Quote.new(value)]
23
+ end.to_h
24
+ }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ module CoinMarketCap
2
+ module Resources
3
+ class Metadata < Resource
4
+ property 'id'
5
+ property 'name'
6
+ property 'symbol'
7
+ property 'category'
8
+ property 'slug'
9
+ property 'logo'
10
+ property 'description'
11
+ property 'date_added', transform_with: ->(v) { iso8601_date(v) }
12
+ property 'notice'
13
+ property 'tags'
14
+ property 'platform', transform_with: lambda { |v|
15
+ CoinMarketCap::Resources::Platform.new(v) unless v.nil?
16
+ }
17
+ property 'urls', transform_with: lambda { |v|
18
+ CoinMarketCap::Resources::URL.new(v) unless v.nil?
19
+ }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ module CoinMarketCap
2
+ module Resources
3
+ class Quote < Resource
4
+ property 'price'
5
+ property 'volume_24h'
6
+ property 'volume_24h_reported'
7
+ property 'volume_7d'
8
+ property 'volume_7d_reported'
9
+ property 'volume_30d'
10
+ property 'volume_30d_reported'
11
+ property 'market_cap'
12
+ property 'market_cap_dominance'
13
+ property 'fully_diluted_market_cap'
14
+ property 'percent_change_1h'
15
+ property 'percent_change_24h'
16
+ property 'percent_change_7d'
17
+ property 'percent_change_30d'
18
+ property 'percent_change_60d'
19
+ property 'percent_change_90d'
20
+ property 'last_updated', transform_with: ->(v) { iso8601_date(v) }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module CoinMarketCap
2
+ module Resources
3
+ class URL < Resource
4
+ property 'website'
5
+ property 'technical_doc'
6
+ property 'explorer'
7
+ property 'source_code'
8
+ property 'message_board'
9
+ property 'chat'
10
+ property 'announcement'
11
+ property 'reddit'
12
+ property 'twitter'
13
+ end
14
+ end
15
+ end
@@ -2,3 +2,7 @@ require_relative 'resources/resource'
2
2
 
3
3
  require_relative 'resources/platform'
4
4
  require_relative 'resources/cryptocurrency'
5
+ require_relative 'resources/url'
6
+ require_relative 'resources/metadata'
7
+ require_relative 'resources/quote'
8
+ require_relative 'resources/listing'
@@ -1,3 +1,3 @@
1
1
  module CoinMarketCap
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinmarketcap-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathusan Selvarajah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-06 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -115,6 +115,7 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/ruby.yml"
118
119
  - ".rubocop.yml"
119
120
  - CHANGELOG.md
120
121
  - CODE_OF_CONDUCT.md
@@ -141,8 +142,12 @@ files:
141
142
  - lib/coinmarketcap/errors/permission_denied_error.rb
142
143
  - lib/coinmarketcap/resources.rb
143
144
  - lib/coinmarketcap/resources/cryptocurrency.rb
145
+ - lib/coinmarketcap/resources/listing.rb
146
+ - lib/coinmarketcap/resources/metadata.rb
144
147
  - lib/coinmarketcap/resources/platform.rb
148
+ - lib/coinmarketcap/resources/quote.rb
145
149
  - lib/coinmarketcap/resources/resource.rb
150
+ - lib/coinmarketcap/resources/url.rb
146
151
  - lib/coinmarketcap/version.rb
147
152
  homepage: https://github.com/koffeefinance/coinmarketcap-ruby-client
148
153
  licenses: