A smart wrapper for Lisk node APIs
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
test
.gitignore
README.md
api.js
example.js
index.js
package.json

README.md

Lisk API Wrapper

With love by dakk (2324852447570841050L) and liskit (10310263204519541551L) delegates

A smart wrapper for Lisk node APIs.

Docs

Full documentation is here.

Source

/docs

Installation

npm install liskapi

Examples

A lot of basic examples can be found in the example.js file.

Basic usage

    const lisk = require ('liskapi')();

    lisk.getSyncStatus ().call ()
    .then ((res) => {
        console.log (`Got data ${res}`);
    })
    .catch ((err) => {
        console.log ('Got an error');
    });

Get with params

    lisk.getBalance ({address: 'address'})
        .call ()
        .then ((res) => {
            console.log (`Get balance of delegate\n ${JSON.stringify (res)}`);
        })
        .catch ((err) => {
            console.log ('Got an error in getting balance\n', err);
        });

Post usage

    const lisk = require ('liskapi')();

    lisk.enableForging ()
    .data ({secret: '...'})
    .call ()
    .then ((res) => {
        console.log (`Got data ${res}`);
    })
    .catch ((err) => {
        console.log ('Got an error');
    });

Connect to a node different from local

    const params = {
        host: 'othernode.com',
        port: 8000,
        ssl: true
    };

    const lisk = require ('liskapi')(params);

Pagination semplification

Call an endpoint with pagination; if limit is great than 101, the endpoint will be called many time as required.

    const lisk = require ('liskapi')();

    lisk.getTransactions ()
    .paginate ({ limit: 100, offset: 0 })
    .call ()
    .then ((res) => {
        console.log (`Got data ${res}`);
    })
    .catch ((err) => {
        console.log ('Got an error');
    });

Sorting

    const lisk = require ('liskapi')();

    lisk.getTransactions ()
    .sort ({ time: 'asc' })
    .call ()
    .then ((res) => {
        console.log (`Got data ${res}`);
    })
    .catch ((err) => {
        console.log ('Got an error');
    });

Change host for a given call

    const lisk = require ('liskapi')();

    lisk.getTransactions ()
    .host ({ host: 'othernode2.com', port: 8000, ssl: true })
    .call ()
    .then ((res) => {
        console.log (`Got data ${res}`);
    })
    .catch ((err) => {
        console.log ('Got an error');
    });