I have been looking out for some personal programming projects and doing something with Hive was appealing. Luckily others have already done the hard work of providing libraries to do this. One of these is beem for Python by @holger80.
I will not leap straight into creating transactions yet, but I can do some simple queries. There is documentation for the library and it is a matter of finding the appropriate functions. There are some code examples.
Initially I am trying to replicate some of what Hive Now does. I am using Jupyter Notebook which makes it easy to experiment with small blocks of code. I have put the full notebook on Github in case it is useful to anyone, but this is part of what it does. Notebook makes the links clickable.
You have to install the beem library. I am using Ubuntu Linux, but it should work on other operating systems too. I had to install a few other libraries it depends on. I used this to install beem itself:
pip3 install -U beem
When I tried to import the library in Python itself it did not find it. This fixed it. I am using Python 3.7.4. pip3 seems to be using Python 3.8, so maybe it put things in the wrong location.
python -m pip install beem
Making a connection to Hive is pretty simple. Once you have imported the libraries you just do something like this. beem works with Steem too, so you have to tell it to use Hive instead and there are a couple of ways to do this. The commented parameter on the Account call could be used instead of set_shared_blockchain_instance(hive):
hive = Hive() user ='steevc' max_lines = 10 set_shared_blockchain_instance(hive) acc = Account(user)#, blockchain_instance=hive)
You then have access to your full history of transactions as you would see on Hiveblocks. It is a matter of pulling out appropriate values. Rewards are expressed in VESTS and so need conversion. To get HP for curation I used acc.blockchain.vests_to_hp. Working out the value of a vote may be more complex as I think you would need to look at the HP of the voter. It would be an estimate anyway.
I will look into other functionality. I can customise what this query does to suit my needs. It might be fun with write some sort of bot, but I will probably not use my main account for that and will be careful to not spam the system. Key management is required for that and I will have to make sure I do not expose them in any public code. If I do code a bot then I might want it to run on a Raspberry Pi so I do not need to leave the PC on all the time. I have an LED display for a Pi that could show status messages. I did some of that ages ago.
I am open to other suggestions for things to try.