Module: Binance::Client::REST::Public_API
- Defined in:
- lib/binance/client/rest/public_api.rb
Overview
Public: A Module containing all of the Public API endpoints
Class Method Summary collapse
-
.extended(base) ⇒ Object
Internal: Create Lambda that returns a new Faraday client instance and add it to the REST class instance variable @api.
Instance Method Summary collapse
-
#agg_trades(options) ⇒ Object
Public: Retrieve aggregate trade data for the specified symbol.
-
#all_book_tickers ⇒ Object
Public: Retrieve all book ticker data for all symbols.
-
#all_prices ⇒ Object
Public: Retrieve all price ticker data.
-
#book_ticker(options) ⇒ Object
Public: Retrieve best price per quantity on the order book.
-
#depth(options) ⇒ Object
Public: Retrieve depth information for the specified symbol.
-
#exchange_info ⇒ Object
Public: Retrieve current exchange trading rules and symbol information.
-
#historical_trades(options) ⇒ Object
Public: Retrieve old trade data for the specified symbol.
-
#klines(options) ⇒ Object
Public: Retrieve kline data for the specified symbol.
-
#ping ⇒ Object
Public: Ping the server to test connectivity.
-
#price(options) ⇒ Object
Public: Retrieve price ticker data for the specified symbol.
-
#products ⇒ Object
Public: Retrieve current exchange asset information.
-
#time ⇒ Object
Public: Retrieve the server time in milliseconds.
-
#trades(options) ⇒ Object
Public: Retrieve recent trades for the specified symbol.
-
#twenty_four_hour(options) ⇒ Object
Public: Retrieve 24 hour ticker price data.
Class Method Details
.extended(base) ⇒ Object
Internal: Create Lambda that returns a new Faraday client instance and add it to the REST class instance variable @api. This is called while a new instance of the REST class is created.
base - The base class that is being extended into.
15 16 17 18 19 20 21 22 23 |
# File 'lib/binance/client/rest/public_api.rb', line 15 def self.extended(base) REST.api[:public] = lambda do Faraday.new(url: "#{BASE_URL}/api") do |conn| conn.request :json conn.response :json, content_type: /\bjson$/ conn.adapter base.adapter end end end |
Instance Method Details
#agg_trades(options) ⇒ Object
Public: Retrieve aggregate trade data for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve.
:fromId - The String of which trade ID to fetch from (optional).
:startTime - The Timestamp of when to get trades from in
milliseconds (optional).
:endTime - The Timestamp of when to get trades until in
milliseconds (optional).
:limit - The Number of how many trades to request (optional).
Returns a Hash with the request response
100 101 102 |
# File 'lib/binance/client/rest/public_api.rb', line 100 def agg_trades() request :public, :get, 'aggTrades', end |
#all_book_tickers ⇒ Object
Public: Retrieve all book ticker data for all symbols
Returns a Hash with the request response
161 162 163 |
# File 'lib/binance/client/rest/public_api.rb', line 161 def all_book_tickers request :public, :get, 'bookTicker' end |
#all_prices ⇒ Object
Public: Retrieve all price ticker data
Returns a Hash with the request response
144 145 146 |
# File 'lib/binance/client/rest/public_api.rb', line 144 def all_prices request :public, :get, 'price' end |
#book_ticker(options) ⇒ Object
Public: Retrieve best price per quantity on the order book
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve (optional).
Returns a Hash with the request response
154 155 156 |
# File 'lib/binance/client/rest/public_api.rb', line 154 def book_ticker() request :public, :get, 'bookTicker', end |
#depth(options) ⇒ Object
Public: Retrieve depth information for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve.
:limit - The Number of how many updates to request (optional).
Returns a Hash with the request response
61 62 63 |
# File 'lib/binance/client/rest/public_api.rb', line 61 def depth() request :public, :get, 'depth', end |
#exchange_info ⇒ Object
Public: Retrieve current exchange trading rules and symbol information
Returns a Hash with the request response
42 43 44 |
# File 'lib/binance/client/rest/public_api.rb', line 42 def exchange_info request :public, :get, 'exchangeInfo' end |
#historical_trades(options) ⇒ Object
Public: Retrieve old trade data for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve.
:limit - The Number of how many trades to request (optional).
:fromId - The String of which trade ID to fetch from (optional).
Returns a Hash with the request response
84 85 86 |
# File 'lib/binance/client/rest/public_api.rb', line 84 def historical_trades() request :user_data, :get, 'historicalTrades', end |
#klines(options) ⇒ Object
Public: Retrieve kline data for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve.
:interval - The String of which interval to retrieve (optional).
:fromId - The String of which trade ID to fetch from (optional).
:startTime - The Timestamp of when to get trades from in
milliseconds (optional).
:endTime - The Timestamp of when to get trades until in
milliseconds (optional).
:limit - The Number of how many trades to request (optional).
Returns a Hash with the request response
117 118 119 |
# File 'lib/binance/client/rest/public_api.rb', line 117 def klines() request :public, :get, 'klines', end |
#ping ⇒ Object
Public: Ping the server to test connectivity
Returns a Hash with the request response
28 29 30 |
# File 'lib/binance/client/rest/public_api.rb', line 28 def ping request :public, :get, 'ping' end |
#price(options) ⇒ Object
Public: Retrieve price ticker data for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve (optional).
Returns a Hash with the request response
137 138 139 |
# File 'lib/binance/client/rest/public_api.rb', line 137 def price() request :public, :get, 'price', end |
#products ⇒ Object
Public: Retrieve current exchange asset information. This is an undocumented endpoint.
Returns a Hash with the request response
50 51 52 |
# File 'lib/binance/client/rest/public_api.rb', line 50 def products request :public, :get, 'products' end |
#time ⇒ Object
Public: Retrieve the server time in milliseconds
Returns a Hash with the request response
35 36 37 |
# File 'lib/binance/client/rest/public_api.rb', line 35 def time request :public, :get, 'time' end |
#trades(options) ⇒ Object
Public: Retrieve recent trades for the specified symbol
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve.
:limit - The Number of how many trades to request (optional).
Returns a Hash with the request response
72 73 74 |
# File 'lib/binance/client/rest/public_api.rb', line 72 def trades() request :public, :get, 'trades', end |
#twenty_four_hour(options) ⇒ Object
Public: Retrieve 24 hour ticker price data
options - The Hash which hosts various REST query params.
:symbol - The String of which trading pair to retrieve (optional).
Returns a Hash with the request response
127 128 129 |
# File 'lib/binance/client/rest/public_api.rb', line 127 def twenty_four_hour() request :public, :get, '24hr', end |