meXBT Exchange API Node.js client
A lightweight Node.js client for the meXBT public and private exchange APIs.
Installing
npm install mexbt
Using
All examples in CoffeeScript. Apologies if this is upsetting.
Public API functions
Mexbt = require 'mexbt'api = apiticker consolelogresapitickerpair: 'btcusd' consolelogresapitradesstartIndex: 0count: 1 trade = restrades0 consolelog"Last trade: BTC @ MXN"apitradesByDatestartDate: 0endDate: 12345678 consolelogresapiorderBook consolelogresapiproductPairs consolelogres
Private API functions
Mexbt = require 'mexbt'api = 'key''secret''test@test.com'apiaccountInfo consolelogresapiaccountBalance consolelogres apiaccountTradesstartIndex: -1count: 5 consolelogresapiaccountOrders consolelogresapiaccountDepositAddresses consolelogresapiwithdrawcurrency: 'btc'amount: 0.1sendToAddress: '1xxxx' consolelogres apicreateOrderamount: 0.1 consolelogresapicreateOrderamount: 0.1side: 'sell'pair: 'btcusd' consolelogresapicreateOrderamount: 0.1price: 100side: 'sell'pair: 'btcusd'type: 'limit' consolelogresapimodifyOrderid: 12345action: 'move_to_top' consolelogresapicancelOrderid: 12345 consolelogresapicancelAllOrders consolelogres
Listening to trade, order and order-removed events
If you want to listen to events and react to them, it's pretty simple. Just tell the api what currency pair you want to listen for and setup your listeners. If you want to listen to multiple currency pairs just use multiple Mexbt instances.
Mexbt = require 'mexbt' api = apisubscribeToStream'btcmxn' # btcmxn is also the default pair apion"trade" consolelog" BTC @ MXN" apion'order' consolelog" order added for BTC @ MXN" apion'order-removed' consolelog" order removed"
Unfortunately the order book is pretty "chatty", there are constantly orders being adjusted so keep that in mind, as they will be removed and then added again.