Simple NodeJS Example to Show Average Scores in the Steemit-Wechat Group


average Simple NodeJS Example to Show Average Scores in the Steemit-Wechat Group nodejs SteemIt

average

I have shown a simple NodeJS example that calls the SteemIt Wechat API to get the daily ranking table. The average scores for Reputation, Steem Power, Steem, Effective SP, Voting Power, SBD and Account values are calculated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// @justyy
var request = require("request")
var url = "https://uploadbeta.com/api/steemit/wechat/?cached";
 
request({
    url: url,
    json: true
}, function (error, response, body) {
    if (!error && response.statusCode === 200) {
        var total = 0;      
        var total_rep = 0;
        var total_sbd = 0;
        var total_steem = 0;
        var total_value = 0;
        var total_esp = 0;
        var total_vp = 0;
        var total_sp = 0;
        body.forEach(function(member) {
            total ++;
            total_rep += member['rep'];
            total_sbd += member['sbd'];
            total_steem += member['steem'];
            total_value += member['value'];
            total_esp += member['esp'];
            total_vp += member['vp'];
            total_sp += member['sp'];
        });
        console.log("Total Members = " + total);
        console.log("Average Reputation = " + Math.round(total_rep / total * 100) / 100);
        console.log("Average SBD = " + Math.round(total_sbd / total * 100) / 100);
        console.log("Average Steem = " + Math.round(total_steem / total * 100) / 100);
        console.log("Average Effective SP = " + Math.round(total_esp / total * 100) / 100);
        console.log("Average SP = " + Math.round(total_sp / total * 100) / 100);
        console.log("Average Voting Power = " + Math.round(total_vp / total * 100) / 100);
        console.log("Average Account Value = " + Math.round(total_value / total * 100) / 100);
    }
})
// @justyy
var request = require("request")
var url = "https://uploadbeta.com/api/steemit/wechat/?cached";

request({
    url: url,
    json: true
}, function (error, response, body) {
    if (!error && response.statusCode === 200) {
        var total = 0;      
        var total_rep = 0;
        var total_sbd = 0;
        var total_steem = 0;
        var total_value = 0;
        var total_esp = 0;
        var total_vp = 0;
        var total_sp = 0;
        body.forEach(function(member) {
            total ++;
            total_rep += member['rep'];
            total_sbd += member['sbd'];
            total_steem += member['steem'];
            total_value += member['value'];
            total_esp += member['esp'];
            total_vp += member['vp'];
            total_sp += member['sp'];
        });
        console.log("Total Members = " + total);
        console.log("Average Reputation = " + Math.round(total_rep / total * 100) / 100);
        console.log("Average SBD = " + Math.round(total_sbd / total * 100) / 100);
        console.log("Average Steem = " + Math.round(total_steem / total * 100) / 100);
        console.log("Average Effective SP = " + Math.round(total_esp / total * 100) / 100);
        console.log("Average SP = " + Math.round(total_sp / total * 100) / 100);
        console.log("Average Voting Power = " + Math.round(total_vp / total * 100) / 100);
        console.log("Average Account Value = " + Math.round(total_value / total * 100) / 100);
    }
})

I use the NodeJs + sublime text 3 on windows to run the above Javascript code.

There are many big whales (Steemians with big wealth) who pull up the average scores, therefore, these average figures are not so useful, but this example gives you an idea how to use the SteemIt API using Node.JS request package, which you need to install beforehand via npm install request

You may also like: 你给SteemIt中文微信群拖后腿了么?

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
405 words
Last Post: SteemIt API - Two APIs to get the followers and following list in the Wechat Group
Next Post: The Average, Median, STD of SteemIt Wechat Group

The Permanent URL is: Simple NodeJS Example to Show Average Scores in the Steemit-Wechat Group

Leave a Reply