SteemAPI Tutorial How to get User Information ?

in #steemstem6 years ago

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
  • Sort:  

    wow i don't know about this

    Glad you found out about it :D

    I had no clue about it. Thanks for providing us this knowledge man.

    Wow this can be a great tool in my learning analytics

    Glad you found it useful bud.Feel free to share you're analytics tool with me would be happy to work on that project.

    Release the Kraken! You got a 2.66% upvote from @seakraken courtesy of @ajkapss!

    Some headie information here lol. Good work.

    Congratulations! This post has been upvoted from the communal account, @minnowsupport, by ajkapss from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

    If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
    Be sure to leave at least 50SP undelegated on your account.

    Coin Marketplace

    STEEM 0.30
    TRX 0.12
    JST 0.034
    BTC 63750.99
    ETH 3130.22
    USDT 1.00
    SBD 3.95