Get the number of voters/holders of a Tron SR using apilist

Usage no npm install needed!

<script type="module">
  import apilister from 'https://cdn.skypack.dev/apilister';



Apilister is a small library that allows you to easily:

  • Get the list of voters for a given SR (Super Representant) or candidate on the Tron Blockchain
  • Get the list of token holders for a given token on the Tron Blockchain

It pulls the data from apilist.tronscan.org

Since apilist.tronscan.org provides the information in a http-paginated way, apilister uses a pool of Promises (package es6-promise-pool) to concurrent download all the paginated urls.

{ address, number_votes }


npm install apilister


To retrieve the voters list for candidate TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP , normally you would have pointed your browser to https://apilist.tronscan.org/api/vote?sort=-votes&limit=40&start=0&candidate=TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP

With apilister you just need to do:

var apilister = require("apilister");
var voters_list = apilister.getVoters('TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP'); 
voters_list.then( function(info){ 
        console.log("Number of voters: " + info.total);
        console.log("Total number of votes: " + info.totalVotes );
        console.log("Actual data: " + info.data);
    } );

To retrieve the holders list (ONLY THE FIRST 10K HOLDERS !!) of the token issued by the address TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP, you would have pointed your browser to https://apilist.tronscan.org/api/tokenholders?sort=-balance&limit=50&start=0&count=true&address=TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP

Now instead you just need to do:

var apilister = require("apilister");
var holders_list = apilister.getHolders('TDGy2M9qWBepSHDEutWWxWd1JZfmAed3BP'); 

holders_list.then( function(info){ 
        console.log("Number of holders " + info.total);
        console.log("Actual data: " + info.data );
    } );

A new method has been added in orther to read the holders list from a json file instead of the apilist URL.

    var holders = apilister.getHoldersFromFile("/home/user/holdersABC.json");

The forma of such a json file is ... (yet to be decided 07/06/2019) this:

  "last_updated": 1559808801,
  "start_block": 1338282,
  "end_block": 9873397,
  "blocks_searched": 8535115,
  "token_name": "BeatzCoin",
  "token_id": 1000501,
  "token_issuer": "TGcvY5rcopeyooHcNbxa3XEKVuJws3y9Td",
  "total_holders": 20502,
  "total_tokens": 459222125,
  "data": [ 
          "address": "TGj5DhYY3jMGmMWbX3yGo9t9KrPHQn4eRp",
          "balance": 41024992
          "address": "TUsFSbcbLaTwdjBG1Q6R7WduAfQpsG4xbf",
          "balance": 31617216
        }, ...

Tronair specific methods

There are a couple of methods that probably you wont be insterested in. They are used by tronair because they return the information ready for sqlite insertion:

Methods getVotersTronairFormat and getHoldersTronairFormat

getHoldersTronairFormat("TMykaWQe9YinNb36yE5k4MH9VUEGyKgQQA").then(info => { console.log(JSON.stringify(info);  });

would printout:

    { "size":12,          //length of array 'data'
      "balance":32462,    //sum of all partial balances




Community Node

Community Node is a Tron SR candidate