How to list following and un-following with Steem-js API

in #utopian-io7 years ago (edited)

Repository

e.g. https://github.com/steemit/steem-js

steem-js#1.png

What Will I Learn?

  • You will learn that how to get a list of following and un-following with steem-js

Requirements

State the requirements the user needs in order to follow this tutorial.

  • Basic knowledge of HTML / CSS / Javascript

Difficulty

  • Intermediate

Tutorial Contents

This tutorial will teach you how to get the list of followings from a certain steemit account using this code...

steem.api.getFollowing(follower, startFollowing, followType, limit, function(err, result) {
  console.log(err, result);
});

Let's Begin

I will explain the above code step by step...

  • Inside steem.api.getFollowing the first argument is follower : follower is the account for which you want to get followings, For e.g. if I want to see as "genievot" how much people I am following, then inside the first argument we add "genievot" with quotes because the first argument accept string. You can also give values in variables like ` let follower = "genievot";
  • 2nd Argument: startFollowing is used to see your followings from any index, If you want to see from start then simply use 0 for the argument. It means start from the 0'th index or 1st value.
  • 3rd Argument: followType is used to find for what type of followings you want to get, followType can be "blog" or null. If you want to put blog then use quotes like this "blog" because it accepts a string.
  • 4th Argument: limit is used to get your followings in a list up to a certain limit. Max limit is 1000, any greater value than 1000 will return an error. You can have the lowest limit as well.

Let's Implement this method.

I will use this code but you can change the method parameters accordingly. goto http://steemoc.jaeven.com and use this code. [Steemoc not create by @genievot, it's another developer's project, found in steem projects website.]
let follower = "utopian-io";
let startFollowing = 0;
let followType = 'blog';
let limit = 1000;

steem.api.getFollowing(follower, startFollowing, followType, limit, function(err, result) {
  console.log(err, result);
});

2018-08-22 (2).png

  • General info: You will see the list of followings for your whole life if you followed someone once, even after unfollowing it you will see that guy over the following list due to blockchain nature. So what makes the difference in following and un-following? It's what[] key in JSON. what include the data of your following or un-following. That's why we can use "blog" or null for followType argument, It means to either print Following of "blog" or un-following means null.

2018-08-22 (5).png

Proof of Work Done

https://github.com/genievot/SteemUnfollow - used this API method in this open source project.

Sort:  

Thank you for your contribution.
Below is our feedback per reviewing your work:

  • Your choice for the title is not as clear as needed to reflect the correct content of the tutorial. You could have used Followers instead of following, which is a better expressive English wording.
  • The is really basic information you are presenting here, which can be easily found online elsewhere, with much higher quality.
  • If you are already passing the following type, you do not really need to check the "what" value, unless the param is optional, which I believe it is not.
  • Your tutorial is quite short for a good tutorial, the concept is really minimal. We recommend you aim for capturing at least 2-3 concepts in a single tutorial.
  • You could have done some more activity with the followers, a better display, some cool activity combined with some other function relying on Steem-based data.
  • Your formatting and post layout in general is not well implemented. Putting portions of your actual text under quotes '>' is not really needed, nor does it help with visibility.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @mcfarhat!

So far this week you've reviewed 1 contributions. Keep up the good work!

Thanks, @mcfarhat for judging this post with your expert view, As I just started to work for utopian-io contribution I am learning from mods like you pointing me out on my mistakes and helping me to solve them.

Some of the things I would like to discuss.

  1. Followers express me like those people that are following me. and Following I thought it was like those people that I am following. Oh, It's hard. It's hard for me to find suitable words in English :)

  2. The information I tried to put out in this article is from different stages that are getting combined and making meaning for this method. Like when creating my projects, It was hard to figure out such things so I created it.

  3. The parameter commonly used for this is null, all over the git hub pages, people use this method with null, so I demonstrated here. I was explaining what concept differently. So they can combine what I trying to say.
    So in the tutorial, I also explain what changes happen when you unfollow someone and what not. So probably 2 concepts are covered in this tutorial very well.

  4. If that's so, then I will keep in mind from my next post. I thought I should make it to the point.

  5. I thought it was not good to show creativity, I better tried to stick up with the path natively. (Still didn't get my words but hope you will understand).

  6. I will remember this, Can you share any well-implemented tutorial please thanks.

Hello @genievot, I expected more than console logging the response tbh. The usage of follow API is already clearly documented in Steem Developers docs, instead you could have created an infinite scroll type of html ui to show the incoming data on web page.

I appreciate your suggestion but my motive was to clearly define the working of steem API method. I didn't find any proper documentation for this method except the method is written over docs in steem-js docs GitHub. If you want a tutorial for Calling JSON to show data over HTML than let me know and I will cover that in another tutorial.

Hi @genievot! We are @steem-ua, a new Steem dApp, computing UserAuthority for all accounts on Steem. We are currently in test modus upvoting quality Utopian-io contributions! Nice work!

Hey @genievot
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.17
TRX 0.24
JST 0.034
BTC 96459.90
ETH 2752.56
SBD 0.67