Skip to content

qingweibinary/binary-live-api

 
 

Repository files navigation

binary-live-api

Build Status

Coverage Status

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.

Usage in the Browser

var api = new LiveApi();
api.authorize('yourtoken');
api.getPortfolio();
api.events.on('portfolio', function(data) {
    // do stuff with portfolio data
});

Usage From Node

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
});

Utility Functions

isReady() - true if connected, false if not yet connected or disconnected
send(data)

Unauthenticated Calls

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

Streams

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

Authenticated Calls

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

Calls support Promise

getPortfolio().then(response) {
    console.log(response);
}

About

JS library to consume Binary.com WebSocket API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.5%
  • HTML 0.5%