create account

RE: Python Libraries: Simple... Display your Splinterlands DEC by onw

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @slobberchops/python-libraries-simple-display-your-splinterlands-dec

· @onw ·
$0.12
Well, you piqued my interest!

This got me to install Python 3 and, using PIP to add the requests repository.

After all that I thought I would contribute by adding a total...

Altered the code as follows:

import json, requests

splinterlands_accounts = ["account1", "account2", "account3"]

print("----------------------------------")
print("Account               DEC Total")
print("----------------------------------")

totalDEC = float("0")

for account in splinterlands_accounts:

    url = "https://api2.splinterlands.com/players/balances?username=" + account
    spldata = json.loads(requests.get(url).text)

    for data in spldata:
        if data["token"] == "DEC":
            spaces = " " * (20-len(data['player']))
            print("{} {} {}".format(data['player'], spaces, data['balance']))
            totalDEC = totalDEC + float(data['balance'])

print("----------------------------------")
spaces = " " * (18-len(str(totalDEC)))
print("{} {} {}".format("Total DEC", spaces, str(totalDEC)))
print("----------------------------------")
👍  ,
properties (23)
authoronw
permlinkre-slobberchops-rjyipa
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-18 16:20:03
last_update2022-10-18 16:20:03
depth1
children1
last_payout2022-10-25 16:20:03
cashout_time1969-12-31 23:59:59
total_payout_value0.061 HBD
curator_payout_value0.061 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,051
author_reputation15,954,360,789,244
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,575,119
net_rshares204,008,716,608
author_curate_reward""
vote details (2)
@slobberchops ·
Great, have a go at doing something else, and install the BEEM library.., then you can truly manipulate HIVE stuff.
properties (22)
authorslobberchops
permlinkre-onw-rjymlm
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-18 17:44:12
last_update2022-10-18 17:44:12
depth2
children0
last_payout2022-10-25 17:44:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length115
author_reputation2,427,110,227,685,880
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,577,240
net_rshares0