It is still an early beta, so there are bound to be bugs, and there is no install script available nor is there support yet for signed operations, but still, I believe this early beta is promising enough to dedicate a post to. If you develop or would like to develop against the STEEM JSON-RPC API and your language of choice is Python, of cause, there is Piston and there is steem-python, and they have their pro's, including the fact that they do support signed operations, but they also have their cons.
I won't tire you with why and how getting fed up with the flaky error handling and other aspects of steem-python led me to starting with asyncsteem. The prime reason for asyncsteem isn't my discontent with the other libraries implementations. If it was I'dd have dived into the source base and would have started producing pull requests. And to be fair, at this early stage I'dd emegine some flaky error handling can be found in asyncsteem as well.
The main reason was the fact that the other options :
- Required a lot of boilerplate for a simple bot
- Weren't designed to work with asynchronous frameworks such as Twisted or AsyncIO
- Weren't really suitable for easy deployment of personal bots to a larger userbase.
The library is far from done, but it now has reached a point where I'm happy about the base API. It's a relatively simple API based around the Twisted asynchronous framework, a simple transparent command queue and an asynchronous command-client setup that uses a maximum of 16 parallel HTTPS queries.
- The library auto-rotates between API nodes on errors or timeouts.
- You can start streaming at the now point in time, or at 0:00 GMT a set number of days in the past. This should prove handy for testing and stats generation with limited on-line time.
- Runs on good old Python 2.7
- Fully asynchronous API using the Twisted framework.
I won't rehash my project's README here, but here is a piece of example code on how to use asyncsteem:
from twisted.internet import reactor from asyncsteem import ActiveBlockChain class DemoBot: def vote(self,tm,vote_event,client): def process_vote_content(event, client): for vote in event["active_votes"]: if vote["voter"] == vote_event["voter"] and vote["rshares"] != 0: print vote["time"],vote["voter"],"=>",vote_event["author"],vote["rshares"] def oops(errno, msg, rpcclient): print "OOPS:",msg,"(",errno,")" opp = client.get_content(vote_event["author"],vote_event["permlink"]) opp.on_result(process_vote_content) opp.on_error(oops) bot = DemoBot() blockchain = ActiveBlockChain(reactor) blockchain.register_bot(bot,"demobot") reactor.run()
Almost fully self-explanatory, right? Well, not quite if you are new to steem development, but I hope that if you have worked with piston/steem-python, you will understand the amount of boilerplate code the API above removes, next to, for those of you familiar with Twisted, the possibilities of integrating with other network operations.
I know, without install scripts, pip installability and signing, it is still far from production ready for most purposes. But not for playing around with the API, you can do that now and you can see what you like and what you don't.
I would like to invite you to give this early beta a bit of a spin and let me know if you see anything that requires rethinking.
All input is appreciated, and if you would like to lend a hand tp this project in any way you feel you can, that would be amazing.