Giter Site home page Giter Site logo

btsdex's Introduction

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.

btsdex's People

Contributors

scientistnik avatar technologiespro avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.