Steemit API + Python: Calculate Your Steemit Spending!

Words
147
Reading
1 min
Listen
Play
9y

steemit

Another discussion with themarkymark@themarkymark, another DIY Seemit report! ;)

We were trying to figure out if I was over-spending on my Steemit activities.

I have a tendency to get carried away with spending money, physical or crypto. Had I gone overboard with my SBD investment?

Using the approximately accurate math ( reward * 0.75 / 2 ) we can roughly determine the SBD I get back from an article.

payout=(( Amount(post["pending_payout_value"]).amount * 0.75) /2)

Therefore we can see what the actual reward was or forthcoming reward might be.

payout = (Amount(post["total_payout_value"]).amount - Amount(post["curator_payout_value"]).amount)

How do we tell how much I spent?

Code

from steem import Steem
s = Steem()


import time, random, os

rposts = s.get_account_history('makerhacks',-1,10000)

total = 0
for post in rposts:

    operation =  post[1]['op'][0]
    if operation == "transfer":
        if post[1]['op'][1]['from'] == "makerhacks" and not post[1]['op'][1]['to'] == "themarkymark":
            print( post[1]['op'][1]['to'] + "\t\t\t" + str( post[1]['op'][1]['amount'] ))
            total = total + float(post[1]['op'][1]['amount'].replace(' SBD',''))


print ("\n\n" + str(total) + " SBD \n\n\n")

This gets 10,000 transfers where I sent from my account but NOT to themarkymark@themarkymark (because that would have been a loan repayment - yes, he is my Steem loan shark ;) ).

Obviously you would need your own Steemit details and logic there.

See any problems with this? Please share in the comments!

Steemit API + Python: Calculate Your Steemit Spending! | Ecency