Updates on Tower (Hivemind + REST)
Tower is a REST API service on the top Hivemind. It allows you to query a Hivemind database in terms of REST practices.
I have pushed a couple of updates to the Tower in the last couple of days.
Filtering posts by tags (including multiple selections)
With the traditional RPC nodes, you can only filter posts with one tag. If you need to see the posts have both tagA
and tagB
, it's not possible.
Since Hive stores an intersection table between posts and tags, it is possible to query the database for multiple tag filtering. Here is an example SQL query demonstrates that:
SELECT author,
permlink
FROM hive_posts
WHERE id IN (SELECT post_id
FROM hive_post_tags
WHERE tag = 'python'
intersect
SELECT post_id
FROM hive_post_tags
WHERE tag = 'development'
intersect
SELECT post_id
FROM hive_post_tags
WHERE tag = 'utopian-io')
ORDER BY created_at DESC
LIMIT 10;
This query returns the last 10 post with the tags: utopian-io
, development
, and python
. Using that query, I have implemented a filter_by_tags
sub-route on the post_cache.
If you want to get the same list with Tower:
You can add any amount of tags to the filter.
Route changes on /api/v1/posts
and api/v1/post_cache
To retrieve a Post
object or PostCache
object, tower was expecting an internal ID (id on the PostgreSQL) in the detail endpoint.
Since STEEM post objects are unique with the author
/permlink
couple, I have changed to use author/permlink instead of IDs.
Examples:
/api/v1/post_cache/blocktrades/pros-and-cons-of-two-versions-of-steem-proposal-system/
/api/v1/posts/blocktrades/pros-and-cons-of-two-versions-of-steem-proposal-system/
Note: It's required for clients' to update their logic on these endpoints since this change is not backward compatible.
Resteems
Hive stores Resteem actions in its hive_reblogs
table. Tower wasn't exposing that table before, but it's now possible to get the Resteem info in different ways.
- Account's resteems (
/api/v1/accounts/<user>/reblogs
)
- Post's resteems (
post_cache/<author>/<permlink>/reblogs/
)
Votes to the Post
Also added a new endpoint to the post_cache namespace where you can a get a list of votes on a specific post.
Each vote object includes voter
, rshares
, and percent
:
{
"voter": "raphaelle",
"rshares": "1626665936",
"percent": "300"
}
Reputation
field is not exposed since it doesn't have a real use case here.
Public tower nodes
https://tower.emrebeyler.me
by @emrebeylerhttps://hivemind.steemviz.com
by @ausbitbank.https://tower.hive.oracle-d.com
by @oracle-d, @wehmoen.
Pull Requests
- https://github.com/emre/tower/pull/7
- https://github.com/emre/tower/pull/8
- https://github.com/emre/tower/pull/9
- https://github.com/emre/tower/pull/10
- https://github.com/emre/tower/pull/11
- https://github.com/emre/tower/pull/12
Vote for my witness
I do my best to support the blockchain with my skills. If you like what I do, consider casting a vote on via Steemconnect or on steemit.com
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @helo! Keep up the good work!
It's good we have in our community people who take care of the technical aspects as well.
Hi @emrebeyler!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Thanks @emrebeyler for your hard work :)
You should be top20 witness with so much work done towards Hivemind.
Thank you for the kind words! 🙈
This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.
Hey, @emrebeyler!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!