This is a library in Ruby to easily acces the data provided by the btc-e.com API. It was originally being used on BTC-Charts.com, among other places. It is available under a BSD-style license.
Show us some love! 1Lq87gJFDYT5MbCa1rA4LLzttYE9Fw3oQw
The library is available as a rubygem.
gem install btce
Populate the file btce-api-key.yml
along the same lines as the example.
The only thing that 99% of the people using the library will want to do with it:
require 'btce'
ticker = Btce::Ticker.new "btc_usd"
This should return something resembling:
#<Btce::Ticker:0x00000000d5d9a0 @operation="ticker",
@pair="btc_usd",
@json={"ticker"=>{"high"=>127,
"low"=>87.301,
"avg"=>107.1505,
"vol"=>4240695.81634,
"vol_cur"=>39298.55663,
"last"=>115,
"buy"=>115,
"sell"=>114.499,
"server_time"=>1366406293}}>
You can then acces the fields with the predefined methods of the Ticker
class.
This is the parent class for both the PublicAPI
class and the TradeAPI
class.
This is the domain of the server, defaulting to the string btc-e.com
.
This is a list of the short strings for all of the currencies currently supported on btc-e.com.
This is a list of all of the supported currency pairs on btc-e.com.
This indicates how many digits past the decimal place are commonly displayed to humans for a given currency pair.
This class wraps the Trade API calls for BTCE. Parameters are passed to the method as a hashmap. More information on parameters can be found on the API docs here https://btc-e.com/api/documentation
require 'btce'
info = Btce::TradeAPI.new_from_keyfile.get_info
This should return something resembling:
{"success" => 1,
"return" => {"funds" => {"usd" => 2.57460659,
"btc" => 0.00012226,
"ltc" => 3.00815559,
"nmc" => 0,
"rur" => 8.0116908,
"eur" => 0,
"nvc" => 0,
"trc" => 0,
"ppc" => 0,
"ftc" => 0,
"xpm" => 0},
"rights" => {"info" => 1,
"trade" => 0,
"withdraw" => 0},
"transaction_count" => 120,
"open_orders" => 1,
"server_time"=>1385947487}}
This method is used to sign the request with the user’s private API key from btc-e.com.
This is the generic method call to the Trade API. It takes a method from the Trade API, and extra information that is needed for the specific method.
Returns the user’s balance, API privileges associated with the current key, number of transactions and open orders, as well as server time
Returns the user’s trade history
Returns the user’s transaction history
Initiates a trade on the user’s account
Returns a list of active orders
Cancels the user’s order