Posts
let the official steem-python be as easy to use as beem? Dynamically search for available steem API nodes
25
@dappcoder
·0 views
1 min read
steem-python :is Steem the official Python library, has a bip38 encryption wallet and a practical cli utility(steempy). However, for many Chinese users, the pain is that the official steem API node is often inaccessible.
The advantage of beem is that it can automatically find the available steem API nodes. Most of the time, you don't need to worry about network access.
So how to make the official steem-python as easy to use as beem? We can also try to use the function of dynamic switching the steem API node in the steem-python program.
Dynamically switch the stem API node
Demonstration program (dynamic_nodes.py):
import steembase
import steem
from steem.steemd import Steemd
from steem.account import Account
from steem.blockchain import Blockchain
steemd_nodes = [
'https://anyx.io',
'https://steemd.minnowsupportproject.org',
'https://rpc.esteem.app',
'https://api.steemit.com',
'https://api.steem.house',
'https://gtg.steem.house:8090',
'https://appbasetest.timcliff.com',
]
custom_instance = Steemd(nodes=steemd_nodes)
tmpAccount = Account('dappcoder', steemd_instance=custom_instance)
print('tmpAccount:', tmpAccount)
print('')
tmpBlockchain = Blockchain(mode='head', steemd_instance=custom_instance)
print('tmpBlockchain:', tmpBlockchain)
run it:python dynamic_nodes.py