ajkapss avatar

SteemAPI Tutorial How to get User Information ?

ajkapss

Published: 04 Mar 2018 › Updated: 04 Mar 2018SteemAPI Tutorial How to get User Information ?

SteemAPI Tutorial How to get User Information ?

Hey Steemians ,have you ever wondered how websites like steemd.com and steemnow.com are able to display user information in near-real time.

DQmTZk2jTVAm4ZPjFEtp7mXHry9NZcMF4KcMkPWWFhZaZH7.gif

Well today we'll use the Steemit API to do exactly that.We are going to be using jsfiddle if you do not know how to use it i would suggest going to this post .

We are going to be using the following API call
steem.api.getAccounts(['ajkapss'], function(err, result)

Our goal is to perform the following operations.

  • Get Users Latest Post
  • Get User Details Like Reputation,Postcount,etc
  •  
    In order to Get User's latest post we will use the following line of code.
    steem.api.getBlogEntries("ajkapss", 9999, 1, function(err, data)
     
    For more detail's regarding how to use the above method please refer to my post on Getting the latest post
     
     
    In order to get User details we first need to figure out what details are we after.In this post lets try to get the following

    NoDetail'sDescription
    1UsernameUserName Of the Person on steemit
    2PostCountNumber Of Posts on steemit
    3ReputationReputation on steemit
    4MinedTrue or False
    5SBDBalanceSBD Balance on Steemit
    6VotingPowerYou're voting power per 100% vote on steemit

    Once again we are going to be using the following API call
    steem.api.getAccounts(['ajkapss'], function(err, result)

    An important thing to note when using this API call is that almost all the data which we will get will be in the form of an array stored in the variable result.For me to get the individual details for the user I will have to iterate through the array luckily for us we are only looking for one user so we can just use result[0] as that points to the user ajkapss in the API call

    Code needed for implementing

    NoDetail'sCode Needed
    1Usernameresult[0].username
    2PostCountresult[0].post_count
    3Reputationresult[0].reputation
    4Minedresult[0].mined
    5SBDBalanceresult[0].sbd_balance
    6VotingPowerresult[0].voting_power

    As you can see ,this is very straightforward and does not require much programming experience.If you are interested in having a look at the code and trying it out for yourself here it is .

    Sources used

  • API doccumentation
  • Leave SteemAPI Tutorial How to get User Information ? to:

    Written by

    Programmer, Developer ,Computer Scientist

    Read more #steemstem posts


    Best Posts From ajkapss

    We have not curated any of ajkapss's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

    More Posts From ajkapss