max_exchange_api 0.0.1 → 0.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: 2850870981b0e9f2735fdc35f3e651451f8f9098894bbf5a6143e85e3c66c0b2
4
- data.tar.gz: 23d415aae12408c224d3666d95b9b28a24065c92a4bd090ea74bbe20c021510d
3
+ metadata.gz: 71535a1c969d383e36c7af1860aeab28c78f55fb62d0e2ef4cb05c9fe8d0df27
4
+ data.tar.gz: c132f2796b57303bfd288a64f0b14cf966d4117568dadb02b606270c316d08c7
5
5
  SHA512:
6
- metadata.gz: c6be2e2a38315742f6b0cba88399539414e48188b66a71634358eacf312c9fbaf7e35ba65c940defb600a8c998f72a01cb2fa5b8e99d41ffb8cedd8662fc28e7
7
- data.tar.gz: 8f2b9a09f71b0f30a3ecc5785851ca6d759751b83ed98d90685f84305b420557f322872bb73b62cd3226a0466e0f81f8386d87d73cbbb027073a6675cd1c923c
6
+ metadata.gz: f51b1539a5cbc487c325fec8b46e5ef38b6c12f4fd909631769fba2e2d82bdbe8dba39ae0130919ca6951aed220e677ec07f64e5d465907fdb0d4cae7224080d
7
+ data.tar.gz: 2afa7b1325fe0756f92416b33e762b9fd264abb6ff4615d6495c4e1d92e8c265b92f680ce8ede43c4e408503cacd15f8b0d9adf84ce31799ca2d25a4aa360e1c
data/.rubocop.yml CHANGED
@@ -243,7 +243,7 @@ Metrics/ModuleLength:
243
243
  Metrics/ParameterLists:
244
244
  Description: 'Avoid parameter lists longer than three or four parameters.'
245
245
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
246
- Enabled: true
246
+ Enabled: false
247
247
 
248
248
  Metrics/PerceivedComplexity:
249
249
  Description: >-
@@ -337,7 +337,7 @@ Rails/HasAndBelongsToMany:
337
337
 
338
338
  Rails/Output:
339
339
  Description: 'Checks for calls to puts, print, etc.'
340
- Enabled: true
340
+ Enabled: false
341
341
 
342
342
  Rails/ReadWriteAttribute:
343
343
  Description: >-
@@ -812,7 +812,7 @@ Style/NumericLiterals:
812
812
  Add underscores to large numeric literals to improve their
813
813
  readability.
814
814
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
815
- Enabled: true
815
+ Enabled: false
816
816
 
817
817
  Style/OneLineConditional:
818
818
  Description: >-
data/CHANGELOG.md CHANGED
@@ -1 +1,4 @@
1
- ## Change Log
1
+ ## Change Log
2
+
3
+ ### v0.0.1 2021/06/23
4
+ - [#1](https://github.com/khiav223577/max_exchange_api/pull/1) Implement `/depth` API (@khiav223577)
data/README.md CHANGED
@@ -35,16 +35,81 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install max_exchange_api
37
37
 
38
+ ## Default config
39
+
40
+ Change default api timeout time (in seconds)
41
+
42
+ ```rb
43
+ MaxExchangeApi.config.default_timeout = 3
44
+ ```
45
+
38
46
  ## Usage
39
47
 
40
- ### Public Apis
48
+ ### Public Api Examples
41
49
 
42
50
  ```rb
43
51
  @api = MaxExchangeApi::PublicApi.new
44
52
  ```
45
53
 
54
+ #### [GET GET /api/v2/vip_levels](https://max.maicoin.com/documents/api_list#!/public/getApiV2VipLevels)
55
+
56
+ > Get all VIP level fees.
57
+
58
+ <details>
59
+ <summary>Show code</summary>
60
+
61
+ ```rb
62
+ @api.vip_levels
63
+ ```
64
+ </details>
65
+
66
+ #### [GET /api/v2/vip_levels/{level}](https://max.maicoin.com/documents/api_list#!/public/getApiV2VipLevelsLevel)
67
+
68
+ > Get VIP level fee by level.
69
+
70
+ <details>
71
+ <summary>Show code</summary>
72
+
73
+ ```rb
74
+ @api.vip_levels(2)
75
+ ```
76
+ </details>
77
+
78
+ #### [GET /api/v2/currencies](https://max.maicoin.com/documents/api_list#!/public/getApiV2Currencies)
79
+
80
+ > Get all available currencies.
81
+
82
+ <details>
83
+ <summary>Show code</summary>
84
+
85
+ ```rb
86
+ @api.currencies
87
+ ```
88
+ </details>
89
+
90
+ #### [GET /api/v2/k](https://max.maicoin.com/documents/api_list#!/public/getApiV2K)
91
+
92
+ > Get OHLC(k line) of a specific market.
93
+
94
+ <details>
95
+ <summary>Show code</summary>
96
+
97
+ ```rb
98
+ # use default parameters
99
+ @api.k('btctwd')
100
+
101
+ # provide all possible parameters
102
+ @api.k('btctwd', limit: 30, period: 1, timestamp: 1624705402)
103
+ ```
104
+ </details>
105
+
46
106
  #### [GET /api/v2/depth](https://max.maicoin.com/documents/api_list#!/public/getApiV2Depth)
47
107
 
108
+ > Get depth of a specified market.
109
+
110
+ <details>
111
+ <summary>Show code</summary>
112
+
48
113
  ```rb
49
114
  # use default parameters
50
115
  @api.depth('maxtwd')
@@ -52,6 +117,93 @@ Or install it yourself as:
52
117
  # provide all possible parameters
53
118
  @api.depth('maxtwd', limit: 10, sort_by_price: true)
54
119
  ```
120
+ </details>
121
+
122
+ #### [GET /api/v2/trades](https://max.maicoin.com/documents/api_list#!/public/getApiV2Trades)
123
+
124
+ > Get recent trades on market, sorted in reverse creation order.
125
+
126
+ <details>
127
+ <summary>Show code</summary>
128
+
129
+ ```rb
130
+ # use default parameters
131
+ @api.trades('btctwd')
132
+
133
+ # provide all possible parameters
134
+ @api.trades(
135
+ 'maxtwd',
136
+ timestamp: 1624705402,
137
+ from: 68444,
138
+ to: 69444,
139
+ order_by: 'asc',
140
+ pagination: true,
141
+ page: 3,
142
+ limit: 15,
143
+ offset: 5,
144
+ )
145
+ ```
146
+ </details>
147
+
148
+ #### [GET /api/v2/markets](https://max.maicoin.com/documents/api_list#!/public/getApiV2Markets)
149
+
150
+ > Get all available markets.
151
+
152
+ <details>
153
+ <summary>Show code</summary>
154
+
155
+ ```rb
156
+ @api.markets
157
+ ```
158
+ </details>
159
+
160
+ #### [GET /api/v2/summary](https://max.maicoin.com/documents/api_list#!/public/getApiV2Summary)
161
+
162
+ > Overview of market data for all tickers.
163
+
164
+ <details>
165
+ <summary>Show code</summary>
166
+
167
+ ```rb
168
+ @api.summary
169
+ ```
170
+ </details>
171
+
172
+ #### [GET /api/v2/tickers/{path_market}](https://max.maicoin.com/documents/api_list#!/public/getApiV2TickersPathMarket)
173
+
174
+ > Get ticker of specific market.
175
+
176
+ <details>
177
+ <summary>Show code</summary>
178
+
179
+ ```rb
180
+ @api.tickers('btctwd')
181
+ ```
182
+ </details>
183
+
184
+ #### [GET /api/v2/tickers](https://max.maicoin.com/documents/api_list#!/public/getApiV2Tickers)
185
+
186
+ > Get ticker of all markets.
187
+
188
+ <details>
189
+ <summary>Show code</summary>
190
+
191
+ ```rb
192
+ @api.tickers
193
+ ```
194
+ </details>
195
+
196
+ #### [GET /api/v2/timestamp](https://max.maicoin.com/documents/api_list#!/public/getApiV2Timestamp)
197
+
198
+ > Get server current time, in seconds since Unix epoch.
199
+
200
+ <details>
201
+ <summary>Show code</summary>
202
+
203
+ ```rb
204
+ @api.timestamp
205
+ ```
206
+ </details>
55
207
 
56
208
  ## Development
57
209
 
@@ -1,2 +1,3 @@
1
1
  require 'max_exchange_api/version'
2
+ require 'max_exchange_api/config'
2
3
  require 'max_exchange_api/public_api'
@@ -19,7 +19,7 @@ module MaxExchangeApi
19
19
  path,
20
20
  headers: headers,
21
21
  query: query,
22
- timeout: 3,
22
+ timeout: MaxExchangeApi.config.default_timeout,
23
23
  ).parsed_response
24
24
 
25
25
  print_log(:info, "[API] #{uuid} response #{response}")
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaxExchangeApi
4
+ class Config
5
+ attr_accessor :default_timeout
6
+
7
+ def initialize
8
+ @default_timeout = 3
9
+ end
10
+ end
11
+
12
+ @config = Config.new
13
+
14
+ class << self
15
+ attr_reader :config
16
+ end
17
+ end
@@ -6,10 +6,63 @@ module MaxExchangeApi
6
6
  class PublicApi < BaseApi
7
7
  base_uri 'https://max-api.maicoin.com/api/v2'
8
8
 
9
+ def vip_levels(level = nil)
10
+ if level
11
+ send_request(:get, "/vip_levels/#{level}", {})
12
+ else
13
+ send_request(:get, '/vip_levels', {})
14
+ end
15
+ end
16
+
17
+ def currencies
18
+ send_request(:get, '/currencies', {})
19
+ end
20
+
21
+ def k(market, limit: 30, period: 1, timestamp: nil)
22
+ send_request(:get, '/k', market: market, limit: limit, period: period, timestamp: timestamp)
23
+ end
24
+
9
25
  def depth(market, limit: 10, sort_by_price: true)
10
26
  send_request(:get, '/depth', market: market, limit: limit, sort_by_price: sort_by_price)
11
27
  end
12
28
 
29
+ def trades(market, timestamp: nil, from: nil, to: nil, order_by: 'desc', pagination: true, page: 1, limit: 50,
30
+ offset: 0)
31
+ send_request(
32
+ :get,
33
+ '/trades',
34
+ market: market,
35
+ timestamp: timestamp,
36
+ from: from,
37
+ to: to,
38
+ order_by: order_by,
39
+ pagination: pagination,
40
+ page: page,
41
+ limit: limit,
42
+ offset: offset,
43
+ )
44
+ end
45
+
46
+ def markets
47
+ send_request(:get, '/markets', {})
48
+ end
49
+
50
+ def summary
51
+ send_request(:get, '/summary', {})
52
+ end
53
+
54
+ def tickers(market = nil)
55
+ if market
56
+ send_request(:get, "/tickers/#{market}", {})
57
+ else
58
+ send_request(:get, '/tickers', {})
59
+ end
60
+ end
61
+
62
+ def timestamp
63
+ send_request(:get, '/timestamp', {})
64
+ end
65
+
13
66
  protected
14
67
 
15
68
  def send_request(method, path, query)
@@ -1,3 +1,3 @@
1
1
  module MaxExchangeApi
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: max_exchange_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
11
+ date: 2021-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - gemfiles/Gemfile
107
107
  - lib/max_exchange_api.rb
108
108
  - lib/max_exchange_api/base_api.rb
109
+ - lib/max_exchange_api/config.rb
109
110
  - lib/max_exchange_api/helper.rb
110
111
  - lib/max_exchange_api/public_api.rb
111
112
  - lib/max_exchange_api/version.rb