class Binance::Client::REST_FUTURE
Constants
- BASE_URL
- ENDPOINTS
- METHODS
- SignRequestMiddleware
Sign the query string using HMAC(sha-256) and appends to query string
- TEST_BASE_URL
- TimestampRequestMiddleware
Generate a timestamp in milliseconds and append to query string
Public Class Methods
add_query_param(query, key, value)
click to toggle source
# File lib/binance/client/rest.rb, line 65 def self.add_query_param(query, key, value) query = query.to_s query << '&' unless query.empty? query << "#{Faraday::Utils.escape key}=#{Faraday::Utils.escape value}" end
new(api_key: '', secret_key: '', adapter: Faraday.default_adapter, test_api: false)
click to toggle source
# File lib/binance/client/rest.rb, line 45 def initialize(api_key: '', secret_key: '', adapter: Faraday.default_adapter, test_api: false) @clients = {} @clients[:public] = public_client adapter, test_api @clients[:verified] = verified_client api_key, adapter, test_api @clients[:signed] = signed_client api_key, secret_key, adapter, test_api @clients[:withdraw] = withdraw_client api_key, secret_key, adapter, test_api @clients[:public_withdraw] = public_withdraw_client adapter, test_api end
Public Instance Methods
camelize(str)
click to toggle source
# File lib/binance/client/rest.rb, line 71 def camelize(str) str.split('_') .map.with_index { |word, i| i.zero? ? word : word.capitalize }.join end
public_client(adapter, test_api)
click to toggle source
# File lib/binance/client/rest/clients.rb, line 58 def public_client(adapter, test_api) Faraday.new(url: "#{(test_api)? TEST_BASE_URL : BASE_URL}/fapi") do |conn| conn.request :json conn.response :json, content_type: /\bjson$/ conn.adapter adapter end end
public_withdraw_client(adapter, test_api)
click to toggle source
# File lib/binance/client/rest/clients.rb, line 85 def public_withdraw_client(adapter, test_api) Faraday.new(url: "#{(test_api)? TEST_BASE_URL : BASE_URL}/wapi") do |conn| conn.request :json conn.response :json, content_type: /\bjson$/ conn.adapter adapter end end
signed_client(api_key, secret_key, adapter, test_api)
click to toggle source
# File lib/binance/client/rest/clients.rb, line 74 def signed_client(api_key, secret_key, adapter, test_api) Faraday.new(url: "#{(test_api)? TEST_BASE_URL : BASE_URL}/fapi") do |conn| conn.request :json conn.response :json, content_type: /\bjson$/ conn.headers['X-MBX-APIKEY'] = api_key conn.use TimestampRequestMiddleware conn.use SignRequestMiddleware, secret_key conn.adapter adapter end end
verified_client(api_key, adapter, test_api)
click to toggle source
# File lib/binance/client/rest/clients.rb, line 66 def verified_client(api_key, adapter, test_api) Faraday.new(url: "#{(test_api)? TEST_BASE_URL : BASE_URL}/fapi") do |conn| conn.response :json, content_type: /\bjson$/ conn.headers['X-MBX-APIKEY'] = api_key conn.adapter adapter end end
withdraw_client(api_key, secret_key, adapter, test_api)
click to toggle source
# File lib/binance/client/rest/clients.rb, line 93 def withdraw_client(api_key, secret_key, adapter, test_api) Faraday.new(url: "#{(test_api)? TEST_BASE_URL : BASE_URL}/wapi") do |conn| conn.request :url_encoded conn.response :json, content_type: /\bjson$/ conn.headers['X-MBX-APIKEY'] = api_key conn.use TimestampRequestMiddleware conn.use SignRequestMiddleware, secret_key conn.adapter adapter end end