Using Lightsteem to query Hivemind

in hivemind •  6 years ago  (edited)

I use Lightsteem to test and query Hivemind endpoints. Structure-wise, Hive's RPC server part is compatible with the steemd RPC nodes. So, it's a simple configuration touch.

condenser_api

Example to get followers of an account:

from lightsteem.client import Client

c = Client(nodes=["https://hivemind.emrebeyler.me"])
followers = c.get_followers("emrebeyler", "", "blog", 10)
print(followers)

You can find the list of methods here.

hive_api

  • Example to get the database head state
from lightsteem.client import Client

c = Client(nodes=["https://hivemind.emrebeyler.me"])
head_state = c('hive').db_head_state()
print(head_state)

Output:

{'db_head_block': 29371204,
 'db_head_time': '2019-01-11 20:15:51',
 'db_head_age': 10}

  • Auto-complete endpoint
from lightsteem.client import Client

c = Client(nodes=["https://hivemind.emrebeyler.me"])

# search for accounts starting with dpoll, 
# from emrebeyler's perspective.

accounts = c('hive').get_accounts_ac(["dpoll", "emrebeyler"])

print(accounts)

Output:

{'friend': [{'name': 'dpoll.curation',
   'vote_sp': 24280,
   'joined_at': '2018-11-04 09:21:42',
   'reputation': 54.57,
   'context': {'is_following': True}},
  {'name': 'dpoll.sponsors',
   'vote_sp': 0,
   'joined_at': '2018-11-13 06:41:12',
   'reputation': 25.0,
   'context': {'is_following': True}}],
 'global': [{'name': 'dpolly0',
   'vote_sp': 0,
   'joined_at': '2016-08-07 10:01:54',
   'reputation': 25.0},
  {'name': 'dpolls.app',
   'vote_sp': 0,
   'joined_at': '2018-08-27 08:05:54',
   'reputation': 25.0},
  {'name': 'dpoll.xyz',
   'vote_sp': 0,
   'joined_at': '2018-09-21 10:32:06',
   'reputation': 25.0},
  {'name': 'dpoll.test',
   'vote_sp': 0,
   'joined_at': '2018-11-23 20:53:15',
   'reputation': 25.0},
  {'name': 'dpoll.funds',
   'vote_sp': 0,
   'joined_at': '2018-11-19 06:58:42',
   'reputation': 25.0},
  {'name': 'dpoll.economy',
   'vote_sp': 0,
   'joined_at': '2018-05-05 14:55:45',
   'reputation': 25.0},
  {'name': 'dpoll.app',
   'vote_sp': 0,
   'joined_at': '2018-04-23 14:19:00',
   'reputation': 25.0},
  {'name': 'dpoll-xyz',
   'vote_sp': 0,
   'joined_at': '2018-11-16 08:50:45',
   'reputation': 25.0},
  {'name': 'dpoll',
   'vote_sp': 0,
   'joined_at': '2018-03-13 13:23:57',
   'reputation': 25.0}]}

  • get_accounts
from lightsteem.client import Client

c = Client(nodes=["https://hivemind.emrebeyler.me"])

# retrieve basic data of the passed accounts
accounts = c('hive').get_accounts([["foo", "bar"]])

print(accounts)

Output:

[{'name': 'foo',
  'vote_sp': 0,
  'joined_at': '2016-04-05 09:18:45',
  'reputation': 25.0},
 {'name': 'bar',
  'vote_sp': 0,
  'joined_at': '2016-05-01 14:59:12',
  'reputation': 25.0}]

For the Beem fans, it's also possible with Beem's internal GrapheneRPC client.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

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.



I really like your posts. I just at the beginning of the exploring of steem api with python, now I see yet one python library for it, additional to beem and steem-python.

Glad you like my content :-)

One year old !BEER


Hey @emrebeyler, here is a little bit of BEER from @isnochys for you. Enjoy it!

Learn how to earn FREE BEER each day by staking.