First (early) beta for the Python asynchronous STEEM library (asyncsteem)

in steemdev •  last year

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.

Some features:

  • 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"])

bot = DemoBot()
blockchain = ActiveBlockChain(reactor)

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.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

That is awesome! Please continue your journey on and you can get rewarded for all the work you do.

Async python libraries are epic! Looking forward to using it in the future.


I am planning to, that's why I created my pibara-utopian account on github and this @mattockfs account here. I love the idea of utopian and steemconnect, but giving them full access to either my main github account or my main steemit account is just to scary.

I've made a little TODO of things I really need to address. Do you think submitting my projected 0.5.x to utopian would be ok, or should I wait with that untill I'm at 0.7 (signing support (that means voting, posting, etc)) or even 1,0 (full code coverage for tests, docstrings)?


I'd say you qualify for utopian if you have a repo and divide your work in pull requests :)

What your lib is doing is a lot and major features each deserve a post in my opinion.

Yes! This looks promising.

I actually tried using steem-python a few days ago, but the pip install didn't work. I then installed it manually, but there were a lot of external dependencies which did no longer work, so I never got to test it. Have you tried using steem-python lately?


I just did a guide on getting steem-python set up with a free Codenvy account to experiment in the cloud. You might find it helpful!


Hope in a month or so, asyncsteem will be complete enough for someone to do a guide on it like that, and hopefully a bit shorter a guide ;-)


Awesome! Your library looks great, especially for making bots or scaling things up. I'll boot it up when I have a chance, and would be happy to write a guide when it's ready. And yes, the shorter the better :)


Thanks! I'll give it a try:D


Dependencies can be a bit of a problem for steem-python, especially if you try to run it on a Linux VPS or VM that comes with its own version of Python3 that isn't as bleeding edge as the version steem-python requires for its latest hippest checkout.

@marcelmaatkamp did some work on using docker with steem-python in order to tame the dependencies and make deployment a bit more easy. Currently my two bots, @croupierbot and the Watching The Watchers post bot running on @pibarabot use steem-python. For me, when I manage to port both bots to asyncsteem instead, and it runs stable for a number of weeks, having solves some of the performance issues that are keeping me from providing accurate metrics with one of these two bots, that should be the time where asyncsteem could be said to be production ready. Today it's not at that point yet. But the dependencies should be easyer to meet on most target systems, so you could give it a spin, and maybe help out by providing bug reports and feature requests.


Anaconda/Miniconda deserve a mention with regards to systems that aren't running the latest and greatest version of Python. It delivers a complete and up to date Python install on any Linux system, and it came in handy while I was trying to get steem-python running on a cloud VM.


I'll try to give it a spin this week;)