Module: LocalBitcoins::Markets

Included in:
Client
Defined in:
lib/localbitcoins/client/markets.rb

Constant Summary collapse

ROOT =

LocalBitcoins.com provides public trade data available for market chart services and tickers The API is in bitcoincharts.com format Currently supported currencies: ARS, AUD, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, ILS, INR, MXN, NOK, NZD, PLN, RUB, SEK, SGD, THB, USD, ZAR

'https://localbitcoins.com'

Instance Method Summary collapse

Instance Method Details

#orderbook(currency) ⇒ Object



22
23
24
25
# File 'lib/localbitcoins/client/markets.rb', line 22

def orderbook(currency)
  orderbook_uri = open("#{ROOT}/bitcoincharts/#{currency}/orderbook.json")
  Hashie::Mash.new(JSON.parse(orderbook_uri.read)) if orderbook_uri.status.first=='200'
end

#tickerObject



12
13
14
15
# File 'lib/localbitcoins/client/markets.rb', line 12

def ticker
  ticker_uri = open("#{ROOT}/bitcoinaverage/ticker-all-currencies/")
  Hashie::Mash.new(JSON.parse(ticker_uri.read)) if ticker_uri.status.first=='200'
end

#trades(currency, last_tid = nil) ⇒ Object



17
18
19
20
# File 'lib/localbitcoins/client/markets.rb', line 17

def trades(currency, last_tid=nil)
  trade_uri = open("#{ROOT}/bitcoincharts/#{currency}/trades.json?since=#{last_tid}")
  JSON.parse(trade_uri.read) if trade_uri.status.first=='200'
end