create account

New steem dev series - #3 - Learn what the query parameter in getDiscussion calls by voorash

View this thread on: hive.blogpeakd.comecency.com
· @voorash · (edited)
$31.52
New steem dev series - #3 - Learn what the query parameter in getDiscussion calls
Ok, so I am going to cover some of the calls using steem-js. Where possible I will give better examples than in the github examples and I will also show samples of what you will get back.

I want to start with getDiscussions type calls because for anyone first trying to read the docs the query parameter is a bit vague.

```
Steem.api.getDiscussionsByActive(query, function(err, result) {
  console.log(err, result);
});
```

Query takes the following form

```
var query = {
  limit:10, // limits the number of posts returned
  tag: 'funny', // limits posts returned to those with the tag funny
  truncate_body: 0 // limits the number of bytes or body text returned for
                  // each post. 0 returns the whole thing and is the default if you don't include this parameter
};
```

There are still some mysteries to me with this call. You can leave off the tag and the truncate_body and it works as expected but if you leave off the limit you get an empty array as a result and null for the err object.

I will dig around some more and see if I can figure out what happens in the code that causes this and if I find anything I will either include it in the next post or update this one. Also, 100 is the highest limit you can set for this call before it throws an error.

I made another discover which is tag does not always actually mean tag. The following

```
Steem.api.getDiscussionsByFeed({
  //author: 'voorash',
  limit:10,
  tag: 'voorash',}
```
  
  will return the latest 10 items in my feed.  So it would seem tag has been repurposed for some calls.

 This next one took me a bit to figure out because it doesn't return the same value. I honestly can't even imagine what this is used for unless I am missing something. Calling it will return the posts being cashed out right now.  Not in 10 seconds and not 10 seconds ago. 
  
```
  Steem.api.getDiscussionsByCashout({limit:10}
```
     
    I thought it was broken until it finally returned something. I'll tinker around with this one to see if I can figure out if it could ever be useful.

    One last one for tonight and that is because it shows some odd behavior. If I run this without a tag then it lists posts that currently have the most votes.  If I add the tag photography then the first result is from 03/15/2017 at 08:32 but then all the other posts in the returned values are current. I will have to look into that one some more too.
   
```
    Steem.api.getDiscussionsByVotes({limit:10}
```

That is it for tonight but I am going to try to post more on this tomorrow. Once I have a good grasp of each api I plan to submit a pull request to add examples to github.

I'll leave you with my reinterpretation of the new star wars short animation style. With Bizarro Leia.![bizzarroholdewok.jpg](https://steemitimages.com/DQmZweT7DoAAQGZ2Ya4dexNkHzXy6oQNb1C7wMppJCeMdnB/bizzarroholdewok.jpg)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 18 others
properties (23)
authorvoorash
permlinknew-steem-dev-series-3
categorysteemdev
json_metadata{"tags":["steemdev","steemit","dev","tutorial","steem"],"image":["https://steemitimages.com/DQmZweT7DoAAQGZ2Ya4dexNkHzXy6oQNb1C7wMppJCeMdnB/bizzarroholdewok.jpg"],"app":"steemit/0.1","format":"markdown"}
created2017-08-14 06:42:18
last_update2017-08-14 08:32:36
depth0
children8
last_payout2017-08-21 06:42:18
cashout_time1969-12-31 23:59:59
total_payout_value24.244 HBD
curator_payout_value7.280 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,873
author_reputation2,389,786,777,503
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,753,444
net_rshares9,614,189,306,339
author_curate_reward""
vote details (82)
@chanthasam ·
Interesting post ! Thanks for sharing ! Upvoted from @chanthasam
👎  
properties (23)
authorchanthasam
permlinkre-voorash-new-steem-dev-series-3-20170814t064425148z
categorysteemdev
json_metadata{"tags":["steemdev"],"users":["chanthasam"],"app":"steemit/0.1"}
created2017-08-14 06:44:27
last_update2017-08-14 06:44:27
depth1
children0
last_payout2017-08-21 06:44:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length64
author_reputation16,524,088,963,858
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,753,584
net_rshares-124,814,649,177
author_curate_reward""
vote details (1)
@igster · (edited)
Dude, thanks god for this! Official documentation is leaving me clueless on what to put into query-variable and how to filter posts...

Followed! Please make more :)
properties (22)
authorigster
permlinkre-voorash-new-steem-dev-series-3-20170830t001745374z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-08-30 00:17:45
last_update2017-08-30 00:18:03
depth1
children2
last_payout2017-09-06 00:17:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length165
author_reputation17,415,198,441,969
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,285,398
net_rshares0
@voorash ·
$0.14
I will be making more.  I have been very busy on a couple things but I have plans for future posts.
👍  
properties (23)
authorvoorash
permlinkre-igster-re-voorash-new-steem-dev-series-3-20170830t030836588z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-08-30 03:08:36
last_update2017-08-30 03:08:36
depth2
children1
last_payout2017-09-06 03:08:36
cashout_time1969-12-31 23:59:59
total_payout_value0.104 HBD
curator_payout_value0.034 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length99
author_reputation2,389,786,777,503
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,296,596
net_rshares41,238,379,532
author_curate_reward""
vote details (1)
@ionlysaymeep ·
meep
properties (22)
authorionlysaymeep
permlinkre-voorash-re-igster-re-voorash-new-steem-dev-series-3-20170830t030836588z-20170830t034832074z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"meep_bot/0.0.1"}
created2017-08-30 03:48:33
last_update2017-08-30 03:48:33
depth3
children0
last_payout2017-09-06 03:48:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4
author_reputation754,962,855,156
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,299,188
net_rshares0
@jigs3716 ·
wow some new in post i like post....thanks
properties (22)
authorjigs3716
permlinkre-voorash-new-steem-dev-series-3-20170814t080425058z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-08-14 08:04:30
last_update2017-08-14 08:04:30
depth1
children0
last_payout2017-08-21 08:04:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length42
author_reputation115,600,210,863
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,758,382
net_rshares0
@mianfahad ·
Nice post.......
i upvoted your post plz upvote me back!!
👎  
properties (23)
authormianfahad
permlinkre-voorash-new-steem-dev-series-3-20170814t071345416z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-08-14 07:13:48
last_update2017-08-14 07:13:48
depth1
children0
last_payout2017-08-21 07:13:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length57
author_reputation-548,955,562,576
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,755,376
net_rshares-2,339,502,451
author_curate_reward""
vote details (1)
@minnowsupport ·
<p>Congratulations!  This post has been upvoted from the communal account, @minnowsupport, by Voorash from the Minnow Support Project.  It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso.  The goal is to help Steemit grow by supporting Minnows and creating a social network.  Please find us in the <a href="https://discord.gg/HYj4yvw">Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>.  It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p>
properties (22)
authorminnowsupport
permlinkre-voorash-new-steem-dev-series-3-20170814t072333685z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"cosgrove/0.0.1rc3"}
created2017-08-14 07:23:33
last_update2017-08-14 07:23:33
depth1
children0
last_payout2017-08-21 07:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length608
author_reputation148,902,805,319,183
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,755,989
net_rshares0
@pilcrow ·
$0.40
Hey man, just a small tip. If you put in the title what your post is about it's a lot easier for people to see if they want to read it, and also easier to find back if someone wants to remember how to do the things you explain.

Great post by the way, thanks for starting this new series.
👍  , , , , , , ,
properties (23)
authorpilcrow
permlinkre-voorash-2017814t94022810z
categorysteemdev
json_metadata{"tags":"steemdev","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-14 07:40:24
last_update2017-08-14 07:40:24
depth1
children0
last_payout2017-08-21 07:40:24
cashout_time1969-12-31 23:59:59
total_payout_value0.387 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length288
author_reputation2,531,070,549,481
root_title"New steem dev series - #3 - Learn what the query parameter in getDiscussion calls"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id11,756,931
net_rshares127,838,546,807
author_curate_reward""
vote details (8)