Steem-python Step by Step: #1 Getting started

in #steem-dev7 years ago (edited)

portadaStepbystep.png

An easy introduction to begin to take advantage of the official STEEM library for Python and the Command Line Interface, steempy, to improve ourselves in Steemit.

Requirements

  1. Install Python3 from https://www.python.org/.
  2. Your operating system, preferably Linux, if you use Windows then install Python3 (requires Python 3.5 or higher) with Anaconda from https://www.continuum.io/downloads and It is no longer necessary point 1.
  3. For wallet and query operations, an austere computer is enough; i.e., from 1GB RAM, 1.6 GHz CPU, it's OK.

Easy Installation

From your Console an internet connection do:
$pip install steem

In the future to keep steem-python updated:
$pip install -U steem

The library is under active development in https://github.com/steemit/steem-python


First steps

Testing the steem-python installation

If you need more background on the Python language:

  1. Then let's start with the python console, on your system terminal :
    $python

  2. From python3:

>>>from steem import Steem
>>>s = Steem()
>>>s.get_account('jesuscirino')['sbd_balance']   #show SBD balance of the user jesuscirino
>>>'2.980 SBD'
>>>s.get_account('jesuscirino')['upvoting_power']   #show upvote power of the user jesuscirino
>>>9950
>>>s.get_account('jesuscirino').keys() #show all you can query about jesuscirino
dict_keys([ ...
... ... ...
... ])
>>>exit() #If everything works, then for now it's enough python

Testing the CLI utility steempy

Steem-python comes with a BIP38 encrypted wallet and a practical CLI utility called steempy. Open your operating system terminal for test it.

  1. Set a passphrase for steempy use:
    $steempy changewalletpassphrase

  2. Now import your Steem account:
    $steempy importaccount "youraccount"

  3. Show balances or you can add more than one:
    $steempy balance "youraccount" "otheraccount" "other"

  4. List accounts:
    steempy listaccounts

  5. Show help:
    steempy -h

To identifying results in steemit platform see example with my account, in the CLI:
list.png

In steemit:
walletKeys.PNG

On steemd, about balance:veststeemd.PNG

References and thanks

For next blogs I will show more practical examples, different from some very good ones that exist in http://steem.readthedocs.io/en/latest/examples.html

Sort:  

Can not get Steem module to install

Does steempy have a way of transfering steem dollars?

Thanks for this tutorial. This was a beautiful precursor to the steem.readthedocs.io you filled in some questions I had.

Nice good info for the IT guys like me.

The following will be more practical, the goal is for us to learn, thanks

Congratulations @jesuscirino! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments

Click on any badge to view your own Board of Honnor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Looks good. I am very interested in seeing more advanced coding! :)

I'm preparing the next post, with something more elaborate, but open to everyone who gives you the application that most need, greetings

Nice guide. You want to contribute it to Steem Docs ?

I would like very much, how can we start? I like your project.

Ping me at the steemit.chat..

I love steempy! No more cli_wallet complications and timeouts.

Loading...

Something is broken. When I try a simple command that used to work, e.g., "steempy listaccounts", I get a bunch of connection errors.

WARNING:urllib3.connectionpool:Retrying (Retry(total=19, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fae0dbb4278>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /

It spits a bunch of these out, counting from 19 down to 0, and then starts over at 19 again. Never progresses.

This used to work in the VM I had set it up in. Did they change the resources that are pointed at by default to not function, or something?

Would reinstalling a portion of what I had installed, make it work again?

Appreciate any pointers, thanks!

FYI, I found the fix. Searched for "python command line steem example no address associated with hostname" and found this: https://github.com/steemit/steem-python/issues/14

The fix is simple, just run this from a terminal prompt: "steempy set nodes https://api.steemit.com"

Now, "steempy listaccounts" works again.

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 60946.76
ETH 3395.14
USDT 1.00
SBD 2.57