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:

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)


My reblogs are accessible at /accounts/emrebeyler/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.


Link

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

Pull Requests

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

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
12 Comments