create account

Additional endpoints for SteemPlus backend by stoodkev

View this thread on: hive.blogpeakd.comecency.com
· @stoodkev · (edited)
$178.62
Additional endpoints for SteemPlus backend
![image.png](https://cdn.utopian.io/posts/7fdd842cdc4d2b91f76278e958342e67f926image.png)

We have added three new endpoints to help us get data from SteemSQL, for a better flexibility in our extension. It might look like there is not much code behind this update, but I can guarantee that the complex SQL request kept us sweating for a good while.

### New Features
Here are the new routes pushed in this update:
- `/api/get-received-witness-votes/[username]` : Get all the votes received by a witness along with a timestamp, voters Vests and Proxied Vests, for further filtering and sorting.


##### Result for @stoodkev
~~~~
[{"timestamp":"2018-03-12T19:35:39.000Z","account":"ahugehug","totalVests":1741.36062,"accountVests":1741.36062,"proxiedVests":0}, ...]
~~~~
- `/api/get-incoming-delegations/[username]` : Gets incoming delegations for @username. It returns a timestamp, the names of delegators, and the number of Vests being delegated.


##### Result for @stoodkev
~~~~
[{"delegator":"steem-plus","vesting_shares":1026195.2327,"delegation_date":"2017-11-30T18:29:48.000Z"}, ... ]
~~~~

- `/api/get-wallet-content/[username]` : Gets the 500 last items from @username's wallet, including incoming and outgoing transfers and claimed rewards.


##### Result for @stoodkev
~~~~
[{"timestamp":"2018-04-23T09:58:27.000Z","reward_steem":0,"reward_sbd":0,"reward_vests":0,"amount":110.276,"amount_symbol":"SBD","type":"transfer_to","memo":"","to_from":"steem-plus"}, ... ]
~~~~

Additionally, in order to protect the API from abuses, we implemented `express-rate-limit`. It allows us to control the maximum number of calls to the API possible from the same IP address during a certain timeframe.

#### Commits

- [/api/get-received-witness-votes/[username]](https://github.com/stoodkev/steemplus-api/commit/1cfa1075dbf0e534fae306f31998478a0fd515ca): This commit contains the definition of this route as well as the IP rate feature.

- [/api/get-incoming-delegations](https://github.com/stoodkev/steemplus-api/commit/71b0ca015535f6308b29ca019664c6f328f4903c) 


- [/api/get-wallet-content](https://github.com/stoodkev/steemplus-api/commit/4f4c6b5f84fa71431e9a685b1a834db67c3d598b)

For more information consult the updated [README](https://github.com/stoodkev/steemplus-api/commit/19bf42caf9cad17dca3c01f53d3b8afa07901758) and the full list of [commits](https://github.com/stoodkev/steemplus-api/commits/master).

### Coming soon

- More wallet transactions
- Rewards information
- User statistics

### Wanna contribute?

Join us on [Discord](https://discord.gg/96JkJSy "This link will take you away from steemit.com")


### Installation procedures

- Subscribe to SteemSQL (10 SBD/month)
- Clone this repository
- `npm install`
- Set the environment variables (information received by transfer when you subscribe to SteemSQL). These environment variables are `LOGIN`, `PASSWORD`, `SQL_API` and `DB`.
- `npm run start`
- You should be able to test it on `localhost:3000`.

<br/><br/>

<div class="pull-right">
<a href="https://discord.gg/7mqmx2M" rel="noopener" title="This link will take you away from steemit.com">
<img src="https://steemitimages.com/DQmd5CQG5zLjjm2z8289qcLU6eBHJpC5FmgtR3aC1eXnhsi/Adsactly-Logo-200px.png" alt="Go Adsactly">
</a>
</div>

Big shoutout to [@jerrybanfield](/@jerrybanfield) and his budgets project that allow us the speed up the development of SteemPlus!

[@stoodkev](/@stoodkev) and [@cedricguillas](/@cedricguillas) for [@steem-plus](/@steem-plus)  

#### Powered by [@adsactly](/@adsactly)

#### Powered by [@utopian-io](/@utopian-io)

Like what I do? [Vote @stoodkev for witness!](https://v2.steemconnect.com/sign/account-witness-vote?witness=stoodkev&approve=1 "This link will take you away from steemit.com")

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@stoodkev/additional-endpoints-for-steemplus-backend">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 190 others
properties (23)
authorstoodkev
permlinkadditional-endpoints-for-steemplus-backend
categoryutopian-io
json_metadata"{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":129349287,"name":"steemplus-api","full_name":"stoodkev/steemplus-api","html_url":"https://github.com/stoodkev/steemplus-api","fork":false,"owner":{"login":"stoodkev"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","steemdev","dev","news","steemit"],"users":["stoodkev","username"],"links":["https://github.com/stoodkev/steemplus-api/commit/1cfa1075dbf0e534fae306f31998478a0fd515ca","https://github.com/stoodkev/steemplus-api/commit/71b0ca015535f6308b29ca019664c6f328f4903c","https://github.com/stoodkev/steemplus-api/commit/4f4c6b5f84fa71431e9a685b1a834db67c3d598b","https://github.com/stoodkev/steemplus-api/commit/19bf42caf9cad17dca3c01f53d3b8afa07901758","https://github.com/stoodkev/steemplus-api/commits/master","https://discord.gg/96JkJSy","https://discord.gg/7mqmx2M","/@jerrybanfield","/@stoodkev","/@cedricguillas","/@steem-plus","/@adsactly","/@utopian-io","https://v2.steemconnect.com/sign/account-witness-vote?witness=stoodkev&approve=1","https://utopian.io/utopian-io/@stoodkev/additional-endpoints-for-steemplus-backend"],"image":["https://cdn.utopian.io/posts/7fdd842cdc4d2b91f76278e958342e67f926image.png","https://steemitimages.com/DQmd5CQG5zLjjm2z8289qcLU6eBHJpC5FmgtR3aC1eXnhsi/Adsactly-Logo-200px.png"],"moderator":{"account":"justyy","time":"2018-04-23T14:29:08.388Z","pending":false,"reviewed":true,"flagged":false},"questions":{"voters":["justyy"],"answers":[{"question_id":"dev-1","answer_id":3,"user":"justyy","influence":75},{"question_id":"dev-2","answer_id":2,"user":"justyy","influence":75},{"question_id":"dev-3","answer_id":3,"user":"justyy","influence":75},{"question_id":"c-1","answer_id":2,"user":"justyy","influence":75},{"question_id":"c-2","answer_id":3,"user":"justyy","influence":75},{"question_id":"c-3","answer_id":3,"user":"justyy","influence":75},{"question_id":"c-4","answer_id":2,"user":"justyy","influence":75},{"question_id":"c-5","answer_id":3,"user":"justyy","influence":75},{"question_id":"c-6","answer_id":3,"user":"justyy","influence":75}],"total_influence":0,"most_rated":[{"question_id":"dev-1","answer_id":3,"influence":75,"voters":["justyy"]},{"question_id":"dev-2","answer_id":2,"influence":75,"voters":["justyy"]},{"question_id":"dev-3","answer_id":3,"influence":75,"voters":["justyy"]},{"question_id":"c-1","answer_id":2,"influence":75,"voters":["justyy"]},{"question_id":"c-2","answer_id":3,"influence":75,"voters":["justyy"]},{"question_id":"c-3","answer_id":3,"influence":75,"voters":["justyy"]},{"question_id":"c-4","answer_id":2,"influence":75,"voters":["justyy"]},{"question_id":"c-5","answer_id":3,"influence":75,"voters":["justyy"]},{"question_id":"c-6","answer_id":3,"influence":75,"voters":["justyy"]}]},"score":57,"total_influence":75,"staff_pick":null,"config":{"questions":[{"question":"How would you rate the impact of the fixed bugs / new features on the project?","question_id":"dev-1","answers":[{"answer":"Very high - the amount of work is very high.","answer_id":1,"value":20},{"answer":"High - the amount of work is high","answer_id":2,"value":15},{"answer":"Average - the amount of work is average","answer_id":3,"value":10},{"answer":"Low - the amount of work is low.","answer_id":4,"value":5},{"answer":"Very Low - the amount of work is very little.","answer_id":5,"value":0}]},{"question":"How would you rate the quality of the provided code?","question_id":"dev-2","answers":[{"answer":"Very high - the code follows all the best practices and/or is the opposite of trivial.","answer_id":1,"value":20},{"answer":"High - the code follows nearly all the best practices and/or is not trivial at all. ","answer_id":2,"value":15},{"answer":"Average - the code follows most the best practices and/or some parts of it are trivial.","answer_id":3,"value":10},{"answer":"Low - the code doesn't really follow the best practices and/or a lot of it is trivial.","answer_id":4,"value":5},{"answer":"Very low - the code doesn't follow the best practices and is completely trivial.","answer_id":5,"value":0}]},{"question":"How do you rate the target project overall?","question_id":"dev-3","answers":[{"answer":"Very high - the project has a unique value, will (potentially) also be useful to a lot of people and has the potential to keep growing.","answer_id":1,"value":10},{"answer":"High - the project isn't really unique but it is well maintained.","answer_id":2,"value":8},{"answer":"Average - the project is limited or not very well maintained.","answer_id":3,"value":4},{"answer":"Low - quality of the project overall is low.","answer_id":4,"value":2},{"answer":"Very low - quality of the project overall is very low and not well maintained.","answer_id":5,"value":0}]},{"question":"Does the writing style meet the Utopian standard considering formalness, informativeness and clarity of the content?","question_id":"c-1","answers":[{"answer":"It is formal, informative and well written with clear content.","answer_id":1,"value":10},{"answer":"It is informative with clear content but not formal enough.","answer_id":2,"value":5},{"answer":"The contribution could be more informative or contains unrelated information, formality and clarity of the content are good enough.","answer_id":3,"value":4},{"answer":"Not all sections were clear enough but overall holds value for the project.","answer_id":4,"value":2},{"answer":"Not at all.","answer_id":5,"value":0}]},{"question":"Was the provided category template for the editor followed?","question_id":"c-2","answers":[{"answer":"All points of the template were included with additional points as well.","answer_id":1,"value":5},{"answer":"The template was followed without additions.","answer_id":2,"value":4},{"answer":"The template was edited but the points were covered in different way.","answer_id":3,"value":3},{"answer":"Not all points of the template were covered in the contribution but the structure is clear enough.","answer_id":4,"value":3},{"answer":"The template was not followed but the structure is clear enough.","answer_id":5,"value":2},{"answer":"The contents are not clearly structured at all.","answer_id":6,"value":0}]},{"question":"Did the contributor tag other users?","question_id":"c-3","answers":[{"answer":"No other users were tagged by the contributor.","answer_id":1,"value":5},{"answer":"Used tags are reasonable and all tagged people are connected to the project and/or the contribution.","answer_id":2,"value":5},{"answer":"The contribution contains mentions of other users that are not directly related to the contribution but related in other ways.","answer_id":3,"value":2},{"answer":"The contributor misuses tagging of other users.","answer_id":4,"value":0}]},{"question":"Did the contributor ask for upvotes, resteems, follows or witness vote?","question_id":"c-4","answers":[{"answer":"No","answer_id":1,"value":5},{"answer":"Yes, but not in a way that disturbs readability. ","answer_id":2,"value":5},{"answer":"Yes.","answer_id":3,"value":0}]},{"question":"Was a graphical content like images, charts, videos or screenshots included?","question_id":"c-5","answers":[{"answer":"Yes, the graphical content is included and adds more value to the contribution.","answer_id":1,"value":5},{"answer":"No but the contribution works well without graphical content well.","answer_id":2,"value":4},{"answer":"Yes, but most of the graphical content’s purpose is just for presentational matters.","answer_id":3,"value":3},{"answer":"No relevant or useful graphical content is included in the contribution.","answer_id":4,"value":0}]},{"question":"How would you rate the overall added value?","question_id":"c-6","answers":[{"answer":"Extraordinary value to both the project and the open source community overall.","answer_id":1,"value":20},{"answer":"Significant value to the project or open source community.","answer_id":2,"value":15},{"answer":"Some value to the project or open source community.","answer_id":3,"value":10},{"answer":"Little value to the project or open source community.","answer_id":4,"value":5},{"answer":"No obvious value to project or open source community.","answer_id":5,"value":0}]}]}}"
created2018-04-23 11:54:21
last_update2018-04-23 14:29:12
depth0
children5
last_payout2018-04-30 11:54:21
cashout_time1969-12-31 23:59:59
total_payout_value133.812 HBD
curator_payout_value44.810 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,930
author_reputation190,232,841,750,255
root_title"Additional endpoints for SteemPlus backend"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id51,664,802
net_rshares29,036,168,322,928
author_curate_reward""
vote details (254)
@justyy ·
$0.05
Thank you for your contribution. @steemsql  is not free anymore and thus we should be very careful in this as this potentially will make the API server a proxy between users and steemsql.  

However, as I understand this, it is useful to separate logics from the presentation, as you are using the APIs in Chrome extension, thus intelligent users may view-source and get the API directly.

On [here](https://github.com/stoodkev/steemplus-api/blob/master/routes/routes.js), line 86, you are missing a *(NOLOCK)* which might impose load to the steemsql server. And I am not sure this is the 'correct' way to get incoming delegation as you are making assumptions that the ID increases as the timestamp increases. You might want to look at alternative solution such as [here](https://stackoverflow.com/questions/43895890/sql-selecting-the-rows-with-max-timestamp-by-group?rq=1)


----------------------------------------------------------------------
Need help? Write a ticket on https://support.utopian.io.
Chat with us on [Discord](https://discord.gg/uTyJkNm).

**[[utopian-moderator]](https://utopian.io/moderators)**
👍  , , , ,
properties (23)
authorjustyy
permlinkre-stoodkev-additional-endpoints-for-steemplus-backend-20180423t143614370z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-04-23 14:36:18
last_update2018-04-23 14:36:18
depth1
children2
last_payout2018-04-30 14:36:18
cashout_time1969-12-31 23:59:59
total_payout_value0.046 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,116
author_reputation280,616,224,641,976
root_title"Additional endpoints for SteemPlus backend"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id51,691,110
net_rshares9,513,212,129
author_curate_reward""
vote details (5)
@arcange ·
Hey @justyy, thanks for your comment.

I have regular contacts with @stoodkev about his great SteemPlus Chrome add-on and its usage of SteemSQL. We already talked together about "proxy risk" of publicly exposing API and this something @stoodkev perfectly understand.

> you are missing a (NOLOCK) which might impose load to the steemsql server

As explained in [this post](https://steemit.com/steemsql/@arcange/steemsql-update-12-about-locks-and-performances), the NOLOCK hint is no more required.

> making assumptions that the ID increases as the timestamp increases.

This is partially correct. ID indeed increase over time as it is an autonumber column. Anyway, should I implement non-linear blocks processing to improve performances, this assumption would become false.
properties (22)
authorarcange
permlinkre-justyy-re-stoodkev-additional-endpoints-for-steemplus-backend-20180423t162005880z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["justyy","stoodkev"],"links":["https://steemit.com/steemsql/@arcange/steemsql-update-12-about-locks-and-performances"],"app":"steemit/0.1"}
created2018-04-23 16:20:06
last_update2018-04-23 16:20:06
depth2
children1
last_payout2018-04-30 16:20:06
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_length774
author_reputation1,146,606,601,469,178
root_title"Additional endpoints for SteemPlus backend"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id51,707,822
net_rshares0
@stoodkev ·
Thanks for taking the time to help us improve these queries!
properties (22)
authorstoodkev
permlinkre-arcange-re-justyy-re-stoodkev-additional-endpoints-for-steemplus-backend-20180423t172139277z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-23 17:21:39
last_update2018-04-23 17:21:39
depth3
children0
last_payout2018-04-30 17:21:39
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_length60
author_reputation190,232,841,750,255
root_title"Additional endpoints for SteemPlus backend"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id51,716,787
net_rshares0
@michal13171 ·
@stoodkev i found couple errors with semicolon and EOL check this repository https://github.com/michal13171/steemplus-api
properties (22)
authormichal13171
permlinkre-stoodkev-additional-endpoints-for-steemplus-backend-20180517t154431110z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["stoodkev"],"links":["https://github.com/michal13171/steemplus-api"],"app":"steemit/0.1"}
created2018-05-17 15:44:18
last_update2018-05-17 15:44:18
depth1
children0
last_payout2018-05-24 15:44:18
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_length121
author_reputation0
root_title"Additional endpoints for SteemPlus backend"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id56,207,136
net_rshares0
@utopian-io ·
### Hey @stoodkev! Thank you for the great work you've done!
We're already looking forward to your next contribution!
#### Fully Decentralized Rewards
We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.
#### Utopian Witness!
<a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for Utopian Witness!</a> We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

**Want to chat? Join us on Discord https://discord.me/utopian-io**
properties (22)
authorutopian-io
permlinkre-stoodkev-additional-endpoints-for-steemplus-backend-20180425t120112798z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-04-25 12:01:12
last_update2018-04-25 12:01:12
depth1
children0
last_payout2018-05-02 12:01:12
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_length688
author_reputation152,955,367,999,756
root_title"Additional endpoints for SteemPlus backend"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,052,484
net_rshares0