bitmart 0.1.1 → 0.1.2
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 +46 -5
- data/lib/bitmart/api_account.rb +18 -14
- data/lib/bitmart/api_contract.rb +49 -22
- data/lib/bitmart/api_spot.rb +38 -31
- data/lib/bitmart/version.rb +1 -1
- data/lib/bitmart.rb +0 -29
- data/logo.png +0 -0
- 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: 331c0d1b3f641bd1ada25da1bbd2768874c4573fb6d5c8564a37a9a6c670e144
|
4
|
+
data.tar.gz: 8c6c763f9bf98051aaf7c15da957865a2542e41e6d385978a513e285cb318dfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec23ee3b585bc30e49b5ff02e3198d5626236aa5a4c214fc8d1df930f4f9b456001326927c70899e144d24593136ded0d0880300026208af19d5bb8eddd4d55
|
7
|
+
data.tar.gz: 257cfb8620a15319ed9414fb2d57e356226ccae9c0146125c5f0fa6a20bedeea431031672363e76ca7ceaf0a6e425d901f2fc23ed04ed47200542d9fc84af307
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
-
|
1
|
+
[](https://bitmart.com)
|
2
2
|
|
3
|
-
|
3
|
+
# BitMart-Ruby-SDK-API
|
4
|
+
=========================
|
4
5
|
|
5
|
-
|
6
|
+
Python client for the [BitMart Cloud API](http://developer-pro.bitmart.com).
|
7
|
+
|
8
|
+
## Feature
|
9
|
+
=========================
|
10
|
+
- Provides exchange quick trading API
|
11
|
+
- Easier withdrawal
|
12
|
+
- Efficiency, higher speeds, and lower latencies
|
13
|
+
- Priority in development and maintenance
|
14
|
+
- Dedicated and responsive technical support
|
15
|
+
- Provide webSocket apis calls
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
=========================
|
6
19
|
|
7
20
|
## Installation
|
8
21
|
|
@@ -21,8 +34,31 @@ Or install it yourself as:
|
|
21
34
|
$ gem install bitmart
|
22
35
|
|
23
36
|
## Usage
|
37
|
+
=========================
|
38
|
+
* An example of a spot trade API
|
39
|
+
* Replace it with your own API KEY
|
40
|
+
* Run
|
24
41
|
|
25
|
-
|
42
|
+
### API Example
|
43
|
+
```ruby
|
44
|
+
require "bitmart"
|
45
|
+
|
46
|
+
spot = Bitmart::API::V1::Spot.new("api_key")
|
47
|
+
|
48
|
+
alts = spot.get_currencies["data"]["currencies"].map do |c|
|
49
|
+
if c["withdraw_enabled"] == true || c["deposit_enabled"] == true
|
50
|
+
c
|
51
|
+
end
|
52
|
+
end.compact
|
53
|
+
|
54
|
+
my_alts = spot.get_wallet["data"]["wallet"]
|
55
|
+
|
56
|
+
diff_alts = alts.map do |coin|
|
57
|
+
unless my_alts.detect { |h| h["id"] == coin["id"] }
|
58
|
+
coin
|
59
|
+
end
|
60
|
+
end.compact
|
61
|
+
```
|
26
62
|
|
27
63
|
## Development
|
28
64
|
|
@@ -32,8 +68,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
68
|
|
33
69
|
## Contributing
|
34
70
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bastosmichael/bitmart.
|
72
|
+
|
73
|
+
## Release Notes
|
74
|
+
=========================
|
36
75
|
|
76
|
+
** 2021-12-10
|
77
|
+
- Proof of concept Ruby gem build with working API end points.
|
37
78
|
|
38
79
|
## License
|
39
80
|
|
data/lib/bitmart/api_account.rb
CHANGED
@@ -7,8 +7,10 @@ module Bitmart
|
|
7
7
|
attr_reader :api_key
|
8
8
|
attr_reader :api_sign
|
9
9
|
attr_reader :api_memo
|
10
|
+
attr_reader :timestamp
|
11
|
+
attr_reader :signature
|
10
12
|
|
11
|
-
def initialize(api_key = nil,
|
13
|
+
def initialize(api_key = nil, api_sign = nil, api_memo = nil)
|
12
14
|
@api_key = api_key
|
13
15
|
@api_sign = api_sign
|
14
16
|
@api_memo = api_memo
|
@@ -61,11 +63,11 @@ module Bitmart
|
|
61
63
|
# POST https://api-cloud.bitmart.com/account/v1/withdraw/apply
|
62
64
|
def post_withdraw_apply(currency, amount, destination, address, address_memo)
|
63
65
|
params = {
|
64
|
-
'
|
66
|
+
'address': address,
|
67
|
+
'address_memo': address_memo,
|
65
68
|
'amount': amount,
|
69
|
+
'currency': currency,
|
66
70
|
'destination': destination,
|
67
|
-
'address': address,
|
68
|
-
'address_memo': address_memo
|
69
71
|
}
|
70
72
|
request(
|
71
73
|
http_method: :post,
|
@@ -78,9 +80,9 @@ module Bitmart
|
|
78
80
|
def get_deposit_withdraw_history(currency, operationType, offset, limit)
|
79
81
|
params = {
|
80
82
|
'currency': currency,
|
81
|
-
'
|
83
|
+
'limit': limit,
|
82
84
|
'offset': offset,
|
83
|
-
'
|
85
|
+
'operation_type': operationType,
|
84
86
|
}
|
85
87
|
request(
|
86
88
|
http_method: :get,
|
@@ -105,18 +107,20 @@ module Bitmart
|
|
105
107
|
|
106
108
|
def client
|
107
109
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
client.headers['X-BM-KEY'] = api_key if api_key&.present?
|
114
|
-
client.headers['X-BM-SIGN'] = signed if signed&.present?
|
115
|
-
client.headers['X-BM-TIMESTAMP'] = timestamp
|
110
|
+
client.request :url_encoded
|
111
|
+
client.adapter Faraday.default_adapter
|
112
|
+
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
113
|
+
client.headers['X-BM-SIGN'] = @signature if @signature
|
114
|
+
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
118
|
def request(http_method:, endpoint:, params: {})
|
119
|
+
unless http_method == :post && api_memo&.nil? && api_sign&.nil?
|
120
|
+
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
121
|
+
data = [timestamp,"#",api_memo,"#",URI.encode_www_form(params)].join
|
122
|
+
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
123
|
+
end
|
120
124
|
response = client.public_send(http_method, endpoint, params)
|
121
125
|
Oj.load(response.body)
|
122
126
|
end
|
data/lib/bitmart/api_contract.rb
CHANGED
@@ -7,8 +7,10 @@ module Bitmart
|
|
7
7
|
attr_reader :api_key
|
8
8
|
attr_reader :api_sign
|
9
9
|
attr_reader :api_memo
|
10
|
+
attr_reader :timestamp
|
11
|
+
attr_reader :signature
|
10
12
|
|
11
|
-
def initialize(api_key = nil,
|
13
|
+
def initialize(api_key = nil, api_sign = nil, api_memo = nil)
|
12
14
|
@api_key = api_key
|
13
15
|
@api_sign = api_sign
|
14
16
|
@api_memo = api_memo
|
@@ -44,7 +46,7 @@ module Bitmart
|
|
44
46
|
end
|
45
47
|
|
46
48
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/tickers
|
47
|
-
def get_tickers(contractId)
|
49
|
+
def get_tickers(contractId = nil)
|
48
50
|
params = {}
|
49
51
|
params = {'contractID': contractId} if contractId
|
50
52
|
request(
|
@@ -56,7 +58,13 @@ module Bitmart
|
|
56
58
|
|
57
59
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/quote
|
58
60
|
def get_quote(contractId, startTime, endTime, unit, resolution)
|
59
|
-
params = {
|
61
|
+
params = {
|
62
|
+
'contractID': contractId,
|
63
|
+
'endTime': endTime,
|
64
|
+
'resolution': resolution,
|
65
|
+
'startTime': startTime,
|
66
|
+
'unit': unit,
|
67
|
+
}
|
60
68
|
request(
|
61
69
|
http_method: :get,
|
62
70
|
endpoint: "ifcontract/quote",
|
@@ -66,7 +74,13 @@ module Bitmart
|
|
66
74
|
|
67
75
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/indexquote
|
68
76
|
def get_index_quote(indexId, startTime, endTime, unit, resolution)
|
69
|
-
params = {
|
77
|
+
params = {
|
78
|
+
'endTime': endTime,
|
79
|
+
'indexID': indexId,
|
80
|
+
'resolution': resolution,
|
81
|
+
'startTime': startTime,
|
82
|
+
'unit': unit,
|
83
|
+
}
|
70
84
|
request(
|
71
85
|
http_method: :get,
|
72
86
|
endpoint: "ifcontract/indexquote",
|
@@ -85,7 +99,7 @@ module Bitmart
|
|
85
99
|
end
|
86
100
|
|
87
101
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/depth
|
88
|
-
def get_depth(contractId, count)
|
102
|
+
def get_depth(contractId, count = nil)
|
89
103
|
params = {'contractID': contractId}
|
90
104
|
param['count'] = count if count
|
91
105
|
request(
|
@@ -133,14 +147,14 @@ module Bitmart
|
|
133
147
|
# POST https://api-cloud.bitmart.com/contract/v1/ifcontract/submitOrder
|
134
148
|
def post_submit_order(contractId, category, way, openType, leverage, customId, price, vol)
|
135
149
|
params = {
|
136
|
-
'contract_id': contractId,
|
137
150
|
'category': category,
|
138
|
-
'
|
139
|
-
'open_type': openType,
|
140
|
-
'leverage': leverage,
|
151
|
+
'contract_id': contractId,
|
141
152
|
'custom_id': customId,
|
153
|
+
'leverage': leverage,
|
154
|
+
'open_type': openType,
|
142
155
|
'price': price,
|
143
|
-
'vol': vol
|
156
|
+
'vol': vol,
|
157
|
+
'way': way,
|
144
158
|
}
|
145
159
|
request(
|
146
160
|
http_method: :post,
|
@@ -170,7 +184,7 @@ module Bitmart
|
|
170
184
|
end
|
171
185
|
|
172
186
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/userTrades
|
173
|
-
def get_user_trades(contractId, offset, size)
|
187
|
+
def get_user_trades(contractId, offset = nil, size = nil)
|
174
188
|
params = {'contractID': contractId}
|
175
189
|
params['offset'] = offset if offset
|
176
190
|
params['size'] = size if size
|
@@ -213,7 +227,10 @@ module Bitmart
|
|
213
227
|
|
214
228
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/userLiqRecords
|
215
229
|
def get_user_liq_records(contractId, orderId)
|
216
|
-
params = {
|
230
|
+
params = {
|
231
|
+
'contractID': contractId,
|
232
|
+
'orderID': orderId
|
233
|
+
}
|
217
234
|
request(
|
218
235
|
http_method: :get,
|
219
236
|
endpoint: "ifcontract/userLiqRecords",
|
@@ -223,7 +240,10 @@ module Bitmart
|
|
223
240
|
|
224
241
|
# GET https://api-cloud.bitmart.com/contract/v1/ifcontract/positionFee
|
225
242
|
def get_position_fee(contractId, positionId)
|
226
|
-
params = {
|
243
|
+
params = {
|
244
|
+
'contractID': contractId,
|
245
|
+
'positionID': positionId
|
246
|
+
}
|
227
247
|
request(
|
228
248
|
http_method: :get,
|
229
249
|
endpoint: "ifcontract/positionFee",
|
@@ -233,7 +253,12 @@ module Bitmart
|
|
233
253
|
|
234
254
|
# POST https://api-cloud.bitmart.com/contract/v1/ifcontract/marginOper
|
235
255
|
def post_margin_oper(contractId, positionId, vol, operType)
|
236
|
-
params = {
|
256
|
+
params = {
|
257
|
+
'contract_id': contractId,
|
258
|
+
'oper_type': operType,
|
259
|
+
'position_id': positionId,
|
260
|
+
'vol': vol,
|
261
|
+
}
|
237
262
|
request(
|
238
263
|
http_method: :post,
|
239
264
|
endpoint: "ifcontract/marginOper",
|
@@ -245,18 +270,20 @@ module Bitmart
|
|
245
270
|
|
246
271
|
def client
|
247
272
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
client.headers['X-BM-KEY'] = api_key if api_key&.present?
|
254
|
-
client.headers['X-BM-SIGN'] = signed if signed&.present?
|
255
|
-
client.headers['X-BM-TIMESTAMP'] = timestamp
|
273
|
+
client.request :url_encoded
|
274
|
+
client.adapter Faraday.default_adapter
|
275
|
+
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
276
|
+
client.headers['X-BM-SIGN'] = @signature if @signature
|
277
|
+
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
256
278
|
end
|
257
279
|
end
|
258
280
|
|
259
281
|
def request(http_method:, endpoint:, params: {})
|
282
|
+
unless http_method == :post && api_memo&.nil? && api_sign&.nil?
|
283
|
+
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
284
|
+
data = [timestamp,"#",api_memo,"#",URI.encode_www_form(params)].join
|
285
|
+
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
286
|
+
end
|
260
287
|
response = client.public_send(http_method, endpoint, params)
|
261
288
|
Oj.load(response.body)
|
262
289
|
end
|
data/lib/bitmart/api_spot.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'ap'
|
2
|
+
require 'oj'
|
3
|
+
|
1
4
|
module Bitmart
|
2
5
|
module API
|
3
6
|
module V1
|
@@ -7,8 +10,10 @@ module Bitmart
|
|
7
10
|
attr_reader :api_key
|
8
11
|
attr_reader :api_sign
|
9
12
|
attr_reader :api_memo
|
13
|
+
attr_reader :timestamp
|
14
|
+
attr_reader :signature
|
10
15
|
|
11
|
-
def initialize(api_key = nil,
|
16
|
+
def initialize(api_key = nil, api_sign = nil, api_memo = nil)
|
12
17
|
@api_key = api_key
|
13
18
|
@api_sign = api_sign
|
14
19
|
@api_memo = api_memo
|
@@ -35,7 +40,7 @@ module Bitmart
|
|
35
40
|
def get_symbol_detail
|
36
41
|
request(
|
37
42
|
http_method: :get,
|
38
|
-
endpoint: "
|
43
|
+
endpoint: "symbols/details"
|
39
44
|
)
|
40
45
|
end
|
41
46
|
|
@@ -80,7 +85,7 @@ module Bitmart
|
|
80
85
|
end
|
81
86
|
|
82
87
|
# GET https://api-cloud.bitmart.com/spot/v1/symbols/book
|
83
|
-
def get_symbol_book(symbol, precision, size)
|
88
|
+
def get_symbol_book(symbol, precision = nil, size = nil)
|
84
89
|
params = {
|
85
90
|
'symbol': symbol
|
86
91
|
}
|
@@ -118,11 +123,11 @@ module Bitmart
|
|
118
123
|
# POST https://api-cloud.bitmart.com/spot/v1/submit_order
|
119
124
|
def post_submit_limit_buy_order(symbol, size='', price='')
|
120
125
|
params = {
|
121
|
-
'
|
126
|
+
'price': price,
|
122
127
|
'side': 'buy',
|
123
|
-
'type': 'limit',
|
124
128
|
'size': size,
|
125
|
-
'
|
129
|
+
'symbol': symbol,
|
130
|
+
'type': 'limit',
|
126
131
|
}
|
127
132
|
request(
|
128
133
|
http_method: :post,
|
@@ -133,11 +138,11 @@ module Bitmart
|
|
133
138
|
|
134
139
|
def post_submit_limit_sell_order(symbol, size='', price='')
|
135
140
|
params = {
|
136
|
-
'
|
141
|
+
'price': price,
|
137
142
|
'side': 'sell',
|
138
|
-
'type': 'limit',
|
139
143
|
'size': size,
|
140
|
-
'
|
144
|
+
'symbol': symbol,
|
145
|
+
'type': 'limit',
|
141
146
|
}
|
142
147
|
request(
|
143
148
|
http_method: :post,
|
@@ -148,10 +153,10 @@ module Bitmart
|
|
148
153
|
|
149
154
|
def post_submit_market_sell_order(symbol, size='')
|
150
155
|
params = {
|
151
|
-
'symbol': symbol,
|
152
156
|
'side': 'sell',
|
157
|
+
'size': size,
|
158
|
+
'symbol': symbol,
|
153
159
|
'type': 'market',
|
154
|
-
'size': size
|
155
160
|
}
|
156
161
|
request(
|
157
162
|
http_method: :post,
|
@@ -162,10 +167,10 @@ module Bitmart
|
|
162
167
|
|
163
168
|
def post_submit_market_buy_order(symbol, notional='')
|
164
169
|
params = {
|
165
|
-
'
|
170
|
+
'notional': notional,
|
166
171
|
'side': 'buy',
|
172
|
+
'symbol': symbol,
|
167
173
|
'type': 'market',
|
168
|
-
'notional': notional
|
169
174
|
}
|
170
175
|
request(
|
171
176
|
http_method: :post,
|
@@ -177,8 +182,8 @@ module Bitmart
|
|
177
182
|
# POST https://api-cloud.bitmart.com/spot/v2/cancel_order
|
178
183
|
def post_cancel_order(symbol, orderId)
|
179
184
|
params = {
|
185
|
+
'order_id': orderId,
|
180
186
|
'symbol': symbol,
|
181
|
-
'order_id': orderId
|
182
187
|
}
|
183
188
|
request(
|
184
189
|
http_method: :post,
|
@@ -190,8 +195,8 @@ module Bitmart
|
|
190
195
|
# POST https://api-cloud.bitmart.com/spot/v1/cancel_orders
|
191
196
|
def post_cancel_orders(symbol, side)
|
192
197
|
params = {
|
198
|
+
'side': side,
|
193
199
|
'symbol': symbol,
|
194
|
-
'side': side
|
195
200
|
}
|
196
201
|
request(
|
197
202
|
http_method: :post,
|
@@ -203,8 +208,8 @@ module Bitmart
|
|
203
208
|
# GET https://api-cloud.bitmart.com/spot/v1/order_detail
|
204
209
|
def get_user_order_detail(symbol, orderId)
|
205
210
|
params = {
|
211
|
+
'order_id': orderId,
|
206
212
|
'symbol': symbol,
|
207
|
-
'order_id': orderId
|
208
213
|
}
|
209
214
|
request(
|
210
215
|
http_method: :get,
|
@@ -216,10 +221,10 @@ module Bitmart
|
|
216
221
|
# GET https://api-cloud.bitmart.com/spot/v1/orders
|
217
222
|
def get_user_orders(symbol, offset, limit, status)
|
218
223
|
params = {
|
219
|
-
'symbol': symbol,
|
220
|
-
'offset': offset,
|
221
224
|
'limit': limit,
|
222
|
-
'
|
225
|
+
'offset': offset,
|
226
|
+
'status': status,
|
227
|
+
'symbol': symbol,
|
223
228
|
}
|
224
229
|
request(
|
225
230
|
http_method: :get,
|
@@ -231,8 +236,8 @@ module Bitmart
|
|
231
236
|
# GET https://api-cloud.bitmart.com/spot/v1/trades
|
232
237
|
def get_user_order_trades(symbol, orderId)
|
233
238
|
params = {
|
234
|
-
'
|
235
|
-
'
|
239
|
+
'order_id': orderId,
|
240
|
+
'symbol': symbol
|
236
241
|
}
|
237
242
|
request(
|
238
243
|
http_method: :get,
|
@@ -243,9 +248,9 @@ module Bitmart
|
|
243
248
|
|
244
249
|
def get_user_trades(symbol, offset, limit)
|
245
250
|
params = {
|
246
|
-
'
|
251
|
+
'limit': limit,
|
247
252
|
'offset': offset,
|
248
|
-
'
|
253
|
+
'symbol': symbol,
|
249
254
|
}
|
250
255
|
request(
|
251
256
|
http_method: :get,
|
@@ -258,18 +263,20 @@ module Bitmart
|
|
258
263
|
|
259
264
|
def client
|
260
265
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
client.headers['X-BM-KEY'] = api_key if api_key&.present?
|
267
|
-
client.headers['X-BM-SIGN'] = signed if signed&.present?
|
268
|
-
client.headers['X-BM-TIMESTAMP'] = timestamp
|
266
|
+
client.request :url_encoded
|
267
|
+
client.adapter Faraday.default_adapter
|
268
|
+
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
269
|
+
client.headers['X-BM-SIGN'] = @signature if @signature
|
270
|
+
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
269
271
|
end
|
270
272
|
end
|
271
273
|
|
272
274
|
def request(http_method:, endpoint:, params: {})
|
275
|
+
unless http_method == :post && api_memo&.nil? && api_sign&.nil?
|
276
|
+
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
277
|
+
data = [timestamp,"#",api_memo,"#",URI.encode_www_form(params)].join
|
278
|
+
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
279
|
+
end
|
273
280
|
response = client.public_send(http_method, endpoint, params)
|
274
281
|
Oj.load(response.body)
|
275
282
|
end
|
data/lib/bitmart/version.rb
CHANGED
data/lib/bitmart.rb
CHANGED
@@ -8,33 +8,4 @@ require "bitmart/api_system"
|
|
8
8
|
|
9
9
|
module Bitmart
|
10
10
|
class Error < StandardError; end
|
11
|
-
class Client
|
12
|
-
attr_reader :api_key
|
13
|
-
attr_reader :api_sign
|
14
|
-
attr_reader :api_memo
|
15
|
-
|
16
|
-
def initialize(api_key = nil, api_signature = nil, api_memo = nil)
|
17
|
-
@api_key = api_key
|
18
|
-
@api_sign = api_sign
|
19
|
-
@api_memo = api_memo
|
20
|
-
end
|
21
|
-
|
22
|
-
def client
|
23
|
-
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
24
|
-
client.request :url_encoded
|
25
|
-
client.adapter Faraday.default_adapter
|
26
|
-
timestamp = Time.now.getutc.to_i.to_s
|
27
|
-
signature = [timestamp,"#",api_memo,"#",client.params.to_s].join if api_memo&.present?
|
28
|
-
signed = OpenSSL::HMAC.hexdigest("SHA256", signature, api_sign) if signature
|
29
|
-
client.headers['X-BM-KEY'] = api_key if api_key&.present?
|
30
|
-
client.headers['X-BM-SIGN'] = signed if signed&.present?
|
31
|
-
client.headers['X-BM-TIMESTAMP'] = timestamp
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def request(http_method:, endpoint:, params: {})
|
36
|
-
response = client.public_send(http_method, endpoint, params)
|
37
|
-
Oj.load(response.body)
|
38
|
-
end
|
39
|
-
end
|
40
11
|
end
|
data/logo.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitmart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bastos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby client for the BitMart Cloud API - http://developer-pro.bitmart.com.
|
14
14
|
Features include Providing exchange quick trading API, Easier withdrawal, Efficiency,
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/bitmart/api_spot.rb
|
38
38
|
- lib/bitmart/api_system.rb
|
39
39
|
- lib/bitmart/version.rb
|
40
|
+
- logo.png
|
40
41
|
homepage: https://github.com/bastosmichael/bitmart-ruby-sdk-api
|
41
42
|
licenses:
|
42
43
|
- MIT
|