npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apilister

v1.0.17

Published

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

Downloads

24

Readme

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 }

Installation

npm install apilister

Usage

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");
	console.log(JSON.stringify(holders));

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
	  "data":[
			["TKQon5B1HGVYn9h5CAbAaJcdPnbp3A3fja",25000],
			["TABjBtiB9zv3Cdvf4emTMYQuG7iJX42cBg",5346],
			["TSTQnv1U3Y73iAdP6QeAxUmYtWzw3mzxc7",1000],
			["TKKRECX1ioPP85hPb3hBXKbr3uhrwdM16F",497],
			["TECYPERwwWu3wAWCt2CrZT6y18RxXYwzM6",283],
			["TLvzBRbfF5C28adK5kNBY1dJ1ngMcvagxR",150],
			["TTTUCXMthAkmJvtUyzDkuePNCffgNVdqwa",108],
			["TM6zXroav7NcwzhPCqW1CMGEpZU6cxvQTU",50],
			["TTrNGPcDisAB2H1AbNRCb5Eu9EKJwgdMgC",23],
			["TJPXMPMwP2DZuH34u6BzMEMuFZqWUVZCx8",3],
			["TJJR9U6cmHNTnjbdjs34ig8bwb4aaDohtf",1],
			["TB4f4UoPufmwxJrc4DLENVCspqjwSCd4fY",1]
		]
	}

Credits

https://t.me/colradi

https://t.me/CommunityNode

Community Node

Community Node is a Tron SR candidate

http://www.communitynode.org/