Steem.js Update v0.3: Added Formatters and Examples

in #steemjs8 years ago (edited)

Hey JS developers!

I've release an update of Steem.js. Basically it's now including more examples on the test.js file and formatting methods to turn a VEST number to Steem Power and to turn a reputation number to a readable number.

The package is now separate in 2 objects. The first is the steem.api and second is steem.formatter. The API are the standard methods for exploring and interact with the blockchain and formatter will be used to make easy for you to turn a raw data to readable data. Did you ever tried to turn a reputation number to a % like they does in steemit.com? Here is how i would do with steem package:

steem.api.getAccounts(['dan'], function(err, result) {
    var reputation = steem.formatter.reputation(result[0].reputation);
    console.log(reputation);
});

Some others examples:

Get the content of steemit.com/trending/steemit

steem.api.getState('trending/steemit', function(err, result) {
    console.log(err, result);
});

Did you know that work for most of the url? try with '@fabien/posts' or '@fabien/feed' or 'hot'.

Stream operations and log the ones that concern only you

steem.api.streamOperations(function(err, result) {
    if (!err && result[1].author == 'fabien') {
        console.log(result);
    }
});

Get 10 followings of @ned

steem.api.getFollowing('ned', 0, 'blog', 10, function(err, result) {
    console.log(result);
});

Get more examples on the test.js file available on GitHub or the NPM package:

https://www.npmjs.com/package/steem
https://github.com/adcpm/steem

Want to help?

I'm looking for contributor for Steem.js, Steem API and others Open Source Steem projects. Interested? Contact me on the rocket chat my username is @fabien, or on the channel #steemjs. There is a lot stuff to do, i can put you on track. All the Steem Dollar rewards of this article will be used to pay contributor to improve these Steem Open Source projects.

Best

Sort:  

A Typescript library will be better.

Great news! Thanks for the reputation and the conversion of Vests to SP. I posted what I believe is a bug in the getFollowers API here:

https://github.com/adcpm/steem/issues/14