Hello,
This is the 12. post of "steem-python for dummies" series. If you didn't read the older ones take your time and have a look.
In this post, we will explore a couple of calls on steem daemon.
Do you know how Steemit filters the posts in the Condenser interface? Even though I didn't check it implicitly how they're doing, I am pretty much sure they're using discussions API in the steem daemon.
from steem import Steem
s = Steem()
query = {"limit": 5} # limit for 5 posts
for p in s.get_discussions_by_trending(query):
print("%s - %s" % (p["author"], p["permlink"]))
Let's check if that list matches with Steemit interface:
Tip: If you want to filter specific tags, just add a tag parameter to the query dict.
from steem import Steem
s = Steem()
query = {"limit": 5, "tag": "python"} # limit for 5 posts
for p in s.get_discussions_by_trending(query):
print("%s - %s" % (p["author"], p["permlink"]))
This will return last 5 trending posts on #python category.
All of these functions gets a query dict in steem-python which should map to original discussion_query struct defined at steemd database api.
So, after the first example about trending, you can pretty much use all functions with the same structure on query dict.
Tip: Currently, select_authors, select_tags, filter_tags arguments in discussion queries are not supported. See the related issue.
query = {"limit": 10}
for p in s.get_discussions_by_promoted(query):
print("%s - %s" % (p["author"], p["permlink"]))
query = {"limit": 10}
for p in s.get_discussions_by_payout(query):
print("%s - %s" % (p["author"], p["permlink"]))
Discussion filter has a maximum limit on limit parameter. It's 100. What if we want to go back?
It has a simple pagination logic.
query = {
"limit": 10,
"start_author": "canadian-coconut",
"start_permlink": "the-nightmare-before-christmas-familyprotection-series-anna-s-family-story-part-i"
}
for p in s.get_discussions_by_trending(query):
print("%s - %s" % (p["author"], p["permlink"]))
canadian-coconut's this post is currently 10. place in the trending. If I start the query with that post, I will get the trending posts between 10 and 20.
That's all for now. Feel free to ask questions or request topics about steem-python for the incoming posts.