Getting Started with Python 3 and the Steemit API

in python •  7 years ago 

DigitalOcean - Droplets.png

As mentioned elsewhere, I dipped my toes into the Steemit API using Python and an off the shelf virtual server. Several people were interested and wanted to create their own Steem bots, so for those who wanted to do the same, here is what I did.

Installation

First, as the above image shows, I bought a virtual server especially for this. That sounds expensive or maybe even wasteful, but you can get a pretty beefy machine for just $5/mo, and you will more than make that back.

Kicking Off the New Year with New Droplet Plans.png

(I just resized mine for free - noice)

You will also need Python 3 and various libraries. @themarkymark helped me with this because somehow I kept borking it.

Here is the ingredients list:

  • Grab Miniconda3 wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  • Install LibSSL sudo apt-get install libssl-dev
  • Steem python3 -m pip install steem
  • and optionally, bpython python3 -m pip install bpython (this enables a rich Python interface with syntax highlighting etc)

Hello World

To test everything is working, let's create a simple script that uses the Steem class.

The code below will print the current SBD balance of my account :)

# first, we initialize Steem class
from steem import Steem
s = Steem()

# now we can call the API to check the SBD
# and output to the console
print( s.get_account('makerhacks')['sbd_balance'] )

Easy!

The API can do lots of cool stuff, we will dig in over future tutorials.

Make sure you follow me so you don't miss any posts. If you liked this, please upvote :)

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:  

If you use the official steem-python you need to edit the metadata file to change the toml package requirement to use 0.9.3 instead of 0.9.3.1 that was removed by the third party dev.

I have switched my servers to use @furion's version of steem-python which is updated more frequently and doesn't have this problem.

python3 -m pip install -U git+git://github.com/Netherdrake/steem-python

I would make sure you remove the other version before installing this one.

It fixes a few issues I've been having outside of just the installation issue.

Thank you, removing steem and replacing it with furion's version of steem-python helped me also, I was pulling my hair out for last few days.

Thank you! Will do that asap :)

python3 -m pip uninstall steem
python3 -m pip install -U git+git://github.com/Netherdrake/steem-python

I found code that adds a member (follows it) and you were handy lol, I had to test if steemit library in Python is working, so I tried and you were added. So just so you know, you were added by python script ;-)
Now that I know everything is working, now I need to find some useful code ;-)

Cool 😎

  ·  7 years ago (edited)

i am glad you are learning steem-python. Themarkymark was a large help to me also. I have a few things built but am new to python so its a work in progress. Ill be keeping an eye out for more. I am in discord and steemit.chat if you need help, or more likely., I need help.

very interesting topic.
are you already using the robot and how much are you earning?

I built a tool to help me with my curated roundup posts "best of steemit", it helps me read a lot faster and find the best stuff :)

ok thanks

@makerhacks what kind of bot you are about to make plz elaborate if possible I have some ideas to share but have no time to work on Python as I am not much aware of it