steem-js icon indicating copy to clipboard operation
steem-js copied to clipboard

Get all voters from a defined Witness

Open RenaudHeitz opened this issue 7 years ago • 3 comments

I'm looking for an API call in order to get all the people that vote for a given Witness in Node JS.

I've looked over : getAccountVotes() method, but it returns the Witness voted by the given account.

I'm also trying getWitnesses() using IDs like this (also tried with "19404" like a String ) : steem.api.getWitnesses([19404], function(err, result) { console.log(err, result); });

But it's returning :

null [ null ]

Is someone has an idea on how I can do that using API calls or any other way to do it ?

RenaudHeitz avatar Mar 12 '18 07:03 RenaudHeitz

You can use

steem.api.getWitnessByAccount(accountName, function(err, result) { console.log(err, result); });

This will return an object that can be filtered the data you need.

AneilPatel05 avatar May 28 '18 05:05 AneilPatel05

No it doesn't? Other than the 'votes' field, there is nothing that will show voter accounts.

wildfunctions avatar Oct 07 '18 04:10 wildfunctions

You can use:

steem.api.call('database_api.list_witness_votes',{start:["curie",""], limit:100, order:"by_witness_account"},function(err, result){console.log(err, result);})

In this command, we check who voted for curie, starting from "", with a limit of 100 votes. The maximum limit is 1000. Then if you need more you have to query again starting from the last vote you got. For instance start:["curie","jga"] starts from the jga's vote.

joticajulian avatar Apr 02 '19 10:04 joticajulian