This library is a high-level abstraction over the Binary.com Websockets API
Note: the master branch represents the latest version of the API. For previous versions (e.g. v2) please see the relevant branches.
var api = new LiveApi();
api.authorize('yourtoken');
api.getPortfolio();
api.events.on('portfolio', function(data) {
// do stuff with portfolio data
});
Install a WebSockets library like 'ws'
npm init
npm install ws --save
npm install binary-live-api --save
Require the library and then pass it to LiveApi's constructor.
var ws = require('ws');
var LiveApi = require('binary-live-api').LiveApi;
var api = new LiveApi({ websocket: ws });
api.authorize('yourtoken');
api.getPortfolio();
api.events.on('portfolio', function(data) {
// do stuff with portfolio data
});
isReady() - true if connected, false if not yet connected or disconnected
send(data)
getTickHistory(symbol, tickHistoryOptions)
Documentation for Tick History API Call
getActiveSymbolsBrief()
Documentation for 'Active Symbols' API Call
getActiveSymbolsFull()
Documentation for 'Active Symbols' API Call
getContractsForSymbol(symbol)
Documentation for 'Contracts For Symbol' API Call
getPayoutCurrencies()
Documentation for 'Payout Currencies' API Call
getTradingTimes(date = Date.now())
Documentation for 'Trading Times' API Call
ping()
Documentation for 'Ping' API Call
getServerTime()
Documentation for 'Server Time' API Call
subscribeToTick(symbol)
Documentation for 'Tick Stream' API Call
subscribeToTicks(arrayOfSymbols)
Documentation for 'Tick Stream' API Call
subscribeToPriceForContractProposal(contractProposal)
Documentation for 'Price Proposal' API Call
subscribeToOpenContract(contractId)
subscribeToAllOpenContracts()
Documentation for 'Price Proposal - Open Contract' API Call
unsubscribeFromTick(symbol)
Documentation for 'Tick Stream' API Call
unsubscribeFromTicks(symbols)
Documentation for 'Tick Stream' API Call
unsubscribeFromAllTicks()
Documentation for 'Forget' API Call
unsubscribeFromAllProposals()
Documentation for 'Forget' API Call
unsubscribeFromAllPortfolios()
Documentation for 'Forget' API Call
unsubscribeFromAllProposalsOpenContract()
Documentation for 'Forget' API Call
authorize(token)
Documentation for 'Authorize' API Call
getBalance()
Documentation for 'Balance' API Call
getStatement(statementOptions = {})
Documentation for 'Statement' API Call
getPortfolio()
Documentation for 'Portfolio' API Call
buyContract(contractId, price)
Documentation for 'Buy Contract' API Call
sellContract(contractId, price)
Documentation for 'Sell Contract' API Call
getPortfolio().then(response) {
console.log(response);
}