[Python] Use Hive2Vests to get list of Witnesses by HP Votes

in #hive-1395316 months ago

Hello Hivers,

We all know converting Vests to Hive can be very confusing, but this issue is particularly annoying for witnesses who want to calculate their received votes and witness rank.

Captura de pantalla 2020-05-06 a la(s) 13.11.26.png

I thought this would make the perfect example of how we can use HIVE2VESTS API to get the list of current witnesses sorted by Hive Power.

This tutorial uses the very simple yet powerfull LightHive python client (Thanks again @emrebeyler), so you would first need to create an environment, install lighthive and activate it.

python3 -m venv env
pip install lighthive
source env/bin/activate

You can then open your favorite editor to create the script witness_list.py:

sudo nano witness_list.py

Copy and paste this script inside it:

from lighthive.client import Client
import json
import requests as r

client = Client()
witness_list = client.get_witnesses_by_vote(None, 125)
count = 0

for witness in witness_list:
    count = count + 1
    account = witness['owner']
    votes = witness['votes']
    hive2vest= r.get('https://hive2vests.chitty.me/api?vests={}'.format(votes)).json()
    votes = float(hive2vest['HIVE']) / 1000000
    votes = "{:,.0f}".format(votes)
    print('{} @{} {} Votes'.format(count, account, votes))


Exit the editor, save the file and run it with:

python witness_list.py


And thats it! you will get the witness list sorted by their Hive Power votes, this is useful for those witnesses who wish to know how many votes they need to move up the rank.

Here is the full list for top 125 witnesses:

1 @gtg 71,152,023 Votes
2 @blocktrades 69,791,141 Votes
3 @themarkymark 67,998,906 Votes
4 @good-karma 67,128,003 Votes
5 @roelandp 66,612,094 Votes
6 @anyx 66,007,853 Votes
7 @ausbitbank 65,855,643 Votes
8 @steempress 63,622,751 Votes
9 @someguy123 62,721,740 Votes
10 @drakos 61,696,184 Votes
11 @therealwolf 60,628,501 Votes
12 @steempeak 58,137,021 Votes
13 @yabapmatt 55,673,574 Votes
14 @abit 55,559,157 Votes
15 @followbtcnews 54,240,822 Votes
16 @arcange 53,384,333 Votes
17 @cervantes 52,285,664 Votes
18 @netuoso 52,168,037 Votes
19 @ocd-witness 51,476,504 Votes
20 @pharesim 51,379,143 Votes
21 @lukestokes.mhth 49,021,875 Votes
22 @aggroed 45,898,008 Votes
23 @stoodkev 44,169,751 Votes
24 @emrebeyler 42,140,131 Votes
25 @curie 38,755,757 Votes
26 @smooth.witness 37,528,656 Votes
27 @riverhead 35,982,788 Votes
28 @thecryptodrive 34,526,457 Votes
29 @quochuy 31,948,014 Votes
30 @jesta 29,773,712 Votes
31 @timcliff 28,280,514 Votes
32 @pfunk 28,227,617 Votes
33 @liondani 25,827,629 Votes
34 @ats-witness 22,998,113 Votes
35 @guiltyparties 21,259,039 Votes
36 @actifit 20,151,434 Votes
37 @holger80 20,030,382 Votes
38 @bhuz 19,434,216 Votes
39 @innerhive 18,984,234 Votes
40 @mahdiyari 17,311,399 Votes
41 @c-squared 15,979,594 Votes
42 @neoxian 11,987,291 Votes
43 @bobinson 11,729,474 Votes
44 @threespeak 11,692,442 Votes
45 @kevinwong 10,870,739 Votes
46 @clayop 10,327,248 Votes
47 @oflyhigh 9,652,365 Votes
48 @jackmiller 9,440,944 Votes
49 @c0ff33a 9,218,406 Votes
50 @steemitboard 8,620,405 Votes
51 @firepower 8,605,891 Votes
52 @nextgencrypto 8,156,711 Votes
53 @patrice 8,056,252 Votes
54 @stem.witness 7,306,464 Votes
55 @ura-soul 7,238,520 Votes
56 @qurator 6,904,608 Votes
57 @klye 6,872,122 Votes
58 @delegate.lafona 6,129,904 Votes
59 @crowdwitness 6,031,994 Votes
60 @r0nd0n 5,659,592 Votes
61 @dragosroua 5,629,108 Votes
62 @engrave 5,599,163 Votes
63 @busy.witness 5,381,344 Votes
64 @fyrst-witness 5,336,771 Votes
65 @blockbrothers 5,331,302 Votes
66 @gerber 4,506,799 Votes
67 @reggaemuffin 4,471,846 Votes
68 @wise-team 4,373,502 Votes
69 @aizensou 4,372,469 Votes
70 @bdcommunity 4,297,516 Votes
71 @steemychicken1 4,128,370 Votes
72 @dsound 4,034,533 Votes
73 @satren 4,003,251 Votes
74 @isnochys 3,810,958 Votes
75 @silversteem 3,761,403 Votes
76 @steemgigs 3,678,119 Votes
77 @enginewitty 3,540,493 Votes
78 @xeldal 3,492,812 Votes
79 @utopian-io 3,481,630 Votes
80 @complexring 3,413,762 Votes
81 @dmitrydao 3,391,834 Votes
82 @rotfl 3,302,693 Votes
83 @coingecko 3,136,600 Votes
84 @b0y2k 2,701,508 Votes
85 @ihashfury 2,556,489 Votes
86 @justyy 2,546,759 Votes
87 @blue-witness 2,511,190 Votes
88 @adsactly-witness 2,466,687 Votes
89 @teamsteem 2,270,122 Votes
90 @jerrybanfield 2,150,118 Votes
91 @lootkit.witness 2,138,504 Votes
92 @partiko 2,088,203 Votes
93 @furion 2,003,778 Votes
94 @cadawg 1,851,178 Votes
95 @deathwing 1,844,391 Votes
96 @techcoderx 1,833,416 Votes
97 @steemed 1,722,556 Votes
98 @tazi 1,652,400 Votes
99 @wackou 1,624,552 Votes
100 @helo 1,542,955 Votes
101 @wehmoen 1,494,353 Votes
102 @lux-witness 1,487,665 Votes
103 @chitty 1,483,172 Votes
104 @oracle-d 1,429,271 Votes
105 @cervisia 1,417,389 Votes
106 @prc 1,409,885 Votes
107 @bue 1,393,734 Votes
108 @roadscape 1,355,122 Votes
109 @ro-witness 1,307,579 Votes
110 @charlieshrem 1,297,773 Votes
111 @steempty 1,245,575 Votes
112 @steemhunt 1,218,874 Votes
113 @lapingvino 1,215,650 Votes
114 @danielsaori 1,175,656 Votes
115 @steemyoda 1,075,261 Votes
116 @dpoll.witness 1,026,197 Votes
117 @arhag 1,025,214 Votes
118 @kushed 1,011,941 Votes
119 @witness.svk 1,006,838 Votes
120 @hagie 931,585 Votes
121 @helpie 894,334 Votes
122 @birdinc 890,980 Votes
123 @joseph 867,487 Votes
124 @yehey 863,863 Votes
125 @blueorgy 810,861 Votes

Enjoy!


If you found this tutorial useful, please consider voting for my witness:
Hivesinger: Vote for Chitty
Hive.Blog: Vote for Chitty

PeakD: Vote for Chitty


Sort:  

This is really a useful Tutorial. Well done! We have featured this post in our 2-days GitPlait-elite post. Keep it coming!

Hey thanks :)

Great list of witnesses to see the vesting on them and the trust on HIVE. I would add also if they run a full node or not in addition along with some other details that could be sorted upon.

Greetings @chitty. I've learned a lot today with your publication. I like python very much and I want to learn more every day. I made the script and it worked perfectly, it threw me a list of 125 witnesses. Taking advantage of adding you as a witness and also @emrebeyler In the future I plan to make a publication about this publication for the Spanish speaking community, if you give me the permission. Excuse my English, I did this with the internet translator. Greetings!