Skip to content

curious2015/btsdex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

btsdex

Package for work with BitShares DEX

Setup

This library can be obtained through npm:

npm install btsdex

Usage

btsdex package contain class BitShares:

const BitShares = require('btsdex')

BitShares contains static methods for work with public API, and dynamic methods for work with wallet API.

Initialization

Example initialization:

BitShares.init('wss://bitshares.openledger.info/ws')

After initialization, you can connect:

BitShares.connect()

BitShares.connect() return Promise, resolve it when connection consists.

You may to subscribe to connection event:

BitShares.subscribe('connected',functionToCall)

Public API

After connection, you may call public api methods. For example BitShares.db return wrapper for database API:

BitShares.db.get_objects(["1.3.0"])
BitShares.db.list_assets("BTS",100)

BitShares.history is wrapper for history API:

BitShares.history.get_market_history("1.3.121","1.3.861","2018-04-04T20:12:22","2018-04-01T20:12:22",86400)

Private API

If you want access to private API, you need create object from BitShares class:

let bot = new BitShares('accountName','privateActiveKey')

bot have buy,sell and cancelOrder methods:

bot.buy(buySymbol, baseSymbol, amount, price, fill_or_kill = false, expire = "2020-02-02T02:02:02")
bot.sell(sellSymbol, baseSymbol, amount, price, fill_or_kill = false, expire = "2020-02-02T02:02:02")
bot.cancelOrder(id)

Some examples:

const BitShares = require('btsdex')
KEY = 'privateActiveKey'

BitShares.init('wss://bitshares.openledger.info/ws')

async function startAfterConnected() {
  let bot = new BitShares('trade-bot',KEY)

  let iam = await BitShares.accounts['trade-bot'];
  let orders = await BitShares.db.get_full_accounts([iam.id],false);
  
  orders = orders[0][1].limit_orders;
  let order = orders[0].sell_price;
  console.log(order)
}

BitShares.subscribe('connected',startAfterConnected)
BitShares.connect()

Documentation

For more information, look wiki.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The package is available as open source under the terms of the MIT License.

About

Package for work with BitShares DEX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%