Steemit API Voting Tutorial

in #steemtutorial7 years ago (edited)

Hey Steemians In this post i going to assume that you have a basic understanding of Javascript and you are here to get familiar with how the Steem API works and what you can do with it.

You can either use steem API from your Machine or Online.In this tutorial i am going to highlight the online version because it might be easier for people to follow that.

  • Your Machine
  • If you do not have steem installed you can do so by running the following command provided you have Node package manager.
    npm install steem --save
    

     

  • Online
  • Interact with the API online using this site(JsFiddle) Other wise if you do not want to worry about all that you can use the CDN and enjoy all the functionality of the steem API.Include the following code in the HTML section of jsfiddle page, this lets the browser know that you would like to use the steem library.
    <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
    

    Now you should have everything configured and you should be able to use the API calls.

  • Voting Using the API
  • We will use the broadcast vote function with the following parameters.

    steem.broadcastVote(privatepostingkey,usernameofvoter,'Usernamevotee','permanent link of the post',vote Percentage,callbackfunction())

    Don't worry if you are confused by Permanent link.Here is a screenshot highlighting what it is.

     
    Finally here is an example to help you out.

    var username = 'ajkapss';
    var privPostingWif ='yourprivatepostingkey'
    steem.broadcast.vote(privPostingWif, username, 'ajkapss', 'c5umhlzr', 10000, function(err, result) {
        console.log(err, result);
        
    });
    
    

    This is how your code should look like if you are using JsFiddle.
     

    Sort:  

    This is soooo Russian and Chinese at the same time for me dude! Let me head back in my oldtimer-cave haha

    Nice tutorial, man :)

    Thanks for sharing this on the platform😊

    Great one my friend

    Congratulations! This post has been upvoted from the communal account, @minnowsupport, by jsonkidd 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.