create account

Steemit API Voting Tutorial by ajkapss

View this thread on: hive.blogpeakd.comecency.com
· @ajkapss · (edited)
$1.81
Steemit API Voting Tutorial
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.
![](https://steemitimages.com/DQmPESUnnEycPYAh7HWVU8XfdU4ypzZXLDgjrGAQWpZsxXS/image.png)
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.
<li> Your Machine</li> 
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
```
&nbsp;
<li> Online</li>
Interact with the API online using this <a href=" https://jsfiddle.net/rj7bqcwn/"> site(JsFiddle)</a>
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.


<li>Voting Using the API</li>


We will use the broadcast vote function with the following parameters.
 <h5>steem.broadcastVote(privatepostingkey,usernameofvoter,'Usernamevotee','permanent link of the post',vote Percentage,callbackfunction())
</h5>
Don't worry if you are confused by Permanent link.Here is a screenshot highlighting what it is.
![](https://steemitimages.com/DQmYfVSZZq1euhbP3ydhniNgbGK4BHJnew9G1mAu69bo2y6/image.png)
&nbsp;
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.
&nbsp;
![](https://steemitimages.com/DQmVfMYL8rzJdN1U3QZkfAvqTMCR7GxYpoXKAkUsdrKZhkE/image.png)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorajkapss
permlinksteemit-api-voting-tutorial
categorysteemtutorial
json_metadata"{"tags":["steemtutorial","steemdev","programming","steemjs","steemapi"],"image":["https://steemitimages.com/DQmPESUnnEycPYAh7HWVU8XfdU4ypzZXLDgjrGAQWpZsxXS/image.png","https://steemitimages.com/DQmYfVSZZq1euhbP3ydhniNgbGK4BHJnew9G1mAu69bo2y6/image.png","https://steemitimages.com/DQmVfMYL8rzJdN1U3QZkfAvqTMCR7GxYpoXKAkUsdrKZhkE/image.png"],"links":[" https://jsfiddle.net/rj7bqcwn/"],"app":"steemit/0.1","format":"markdown"}"
created2018-02-22 02:27:33
last_update2018-02-22 02:30:21
depth0
children6
last_payout2018-03-01 02:27:33
cashout_time1969-12-31 23:59:59
total_payout_value1.476 HBD
curator_payout_value0.329 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,049
author_reputation385,838,591,399
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,491,618
net_rshares325,867,276,037
author_curate_reward""
vote details (49)
@combofrenzy ·
Nice tutorial, man :)
properties (22)
authorcombofrenzy
permlinkre-ajkapss-steemit-api-voting-tutorial-20180222t085625845z
categorysteemtutorial
json_metadata{"tags":["steemtutorial"],"app":"steemit/0.1"}
created2018-02-22 08:56:27
last_update2018-02-22 08:56:27
depth1
children0
last_payout2018-03-01 08:56: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_length21
author_reputation2,031,986,596,129
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,557,621
net_rshares0
@cryptosourov ·
wonderful tutorial. thanks for making this tutorial
properties (22)
authorcryptosourov
permlinkre-ajkapss-steemit-api-voting-tutorial-20180222t094924799z
categorysteemtutorial
json_metadata{"tags":["steemtutorial"],"app":"steemit/0.1"}
created2018-02-22 09:49:30
last_update2018-02-22 09:49:30
depth1
children0
last_payout2018-03-01 09:49: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_length51
author_reputation20,149,359,629
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,567,074
net_rshares0
@elixbaba ·
Great one my friend
properties (22)
authorelixbaba
permlinkre-ajkapss-steemit-api-voting-tutorial-20180222t210043879z
categorysteemtutorial
json_metadata{"tags":["steemtutorial"],"app":"steemit/0.1"}
created2018-02-22 21:00:54
last_update2018-02-22 21:00:54
depth1
children0
last_payout2018-03-01 21:00:54
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_length19
author_reputation1,103,049,897,643
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,696,141
net_rshares0
@karinxxl ·
This is soooo Russian and Chinese at the same time for me dude! Let me head back in my oldtimer-cave haha
properties (22)
authorkarinxxl
permlinkre-ajkapss-steemit-api-voting-tutorial-20180222t023952184z
categorysteemtutorial
json_metadata{"tags":["steemtutorial"],"app":"steemit/0.1"}
created2018-02-22 02:39:51
last_update2018-02-22 02:39:51
depth1
children0
last_payout2018-03-01 02:39:51
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_length105
author_reputation461,945,369,981,487
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,493,936
net_rshares0
@lucky17 ·
Thanks for sharing this on the platform😊
properties (22)
authorlucky17
permlinkre-ajkapss-steemit-api-voting-tutorial-20180222t101053639z
categorysteemtutorial
json_metadata{"tags":["steemtutorial"],"app":"steemit/0.1"}
created2018-02-22 10:10:54
last_update2018-02-22 10:10:54
depth1
children0
last_payout2018-03-01 10:10:54
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_length40
author_reputation82,964,342,896
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id39,571,311
net_rshares0
@minnowsupport ·
<p>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 <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> <p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
properties (22)
authorminnowsupport
permlinkre-steemit-api-voting-tutorial-20180224t212833
categorysteemtutorial
json_metadata""
created2018-02-24 21:28:33
last_update2018-02-24 21:28:33
depth1
children0
last_payout2018-03-03 21:28: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_length1,704
author_reputation148,902,805,319,183
root_title"Steemit API Voting Tutorial"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id40,185,245
net_rshares0