create account

Exploring new Hivemind Community APIs by emrebeyler

View this thread on: hive.blogpeakd.comecency.com
· @emrebeyler ·
$14.23
Exploring new Hivemind Community APIs
[Steemit Beta](https://beta.steemit.com/) is running for a while, hosting the new communities UI, powered by Hivemind in the backend. There is a new set of [API endpoints](https://github.com/steemit/hivemind/blob/214-core/hive/server/serve.py#L115) available.

<center><img src="https://i.imgur.com/XcssYgI.png"></center>
***

It's possible to use these endpoints with [Lightsteem](https://lightsteem.readthedocs.io/en/latest/) in a simple way to explore the API methods. (No updates needed thanks to Lightsteem's dynamic request model)

#### First step, getting a Client instance
***
```
from lightsteem.client import Client

c = Client(nodes=["https://beta-api.steemit.com/"])
```

#### Get community details
***
```
c('bridge').get_community({"name": "hive-129924", "observer": "emrebeyler"})
```
***
Example Output:

```
{
    'id': 1352979,
    'name': 'hive-129924',
    'title': 'Python',
    'about': 'news, questions, notes, tutorials about the Python programming language',
    'lang': 'en',
    'type_id': 1,
    'is_nsfw': False,
    'subscribers': 31,
    'sum_pending': 28,
    'num_pending': 16,
    'num_authors': 9,
    'created_at': '2020-01-04 09:11:06',
    'context': {
        'role': 'admin',
        'title': '',
        'subscribed': True
    },
    'description': '',
    'flag_text': '',
    'settings': {},
    'team': [
        ['hive-129924', 'owner', ''],
        ['emrebeyler', 'admin', ''],
        ['crokkon', 'mod', 'Expert']
    ]
}
```
***
#### List communities
***
```
c('bridge').list_communities({"limit": 1})
```
***
List all communities and limit the results to 1. (It's possible to paginate the results with optional ```last``` argument.)

Example output:
***
```
[{
    'id': 1337319,
    'name': 'hive-100421',
    'title': 'Threespeak',
    'about': '3Speak is a video platform for deplatformed and censored content creators.',
    'lang': 'en',
    'type_id': 1,
    'is_nsfw': False,
    'subscribers': 810,
    'sum_pending': 2770,
    'num_pending': 1912,
    'num_authors': 461,
    'created_at': '2019-11-14 19:51:54',
    'context': {}
}]
```
***
#### List community roles
***
```
c('bridge').list_community_roles({"community": "hive-129924"})
```
***
Example output:
***
```
[
    ['hive-129924', 'owner', ''],
    ['emrebeyler', 'admin', ''],
    ['crokkon', 'mod', 'Expert']
]
```
***
#### List subscribers of a community
***
```
 c('bridge').list_subscribers({"community": "hive-129924"})
```
***
Example output:
***
```
[
    ['cardboard', 'guest', None, '2020-01-05 01:17:51'],
    ['anthonyadavisii', 'guest', None, '2020-01-05 01:11:03'],
    ['mytechtrail', 'guest', None, '2020-01-05 00:52:39'],
    ['louis88', 'guest', None, '2020-01-05 00:50:18'],
    ['dalz', 'guest', '', '2020-01-05 00:45:21'],
    ['emrebeyler', 'admin', '', '2020-01-04 09:11:15'],
    ...
]
```
***
#### List subscriptions of an account
***
```
c('bridge').list_all_subscriptions({"account": "emrebeyler"})
```
***
Example output:
***
```
[
    ['hive-129924', 'Python'],
    ['hive-174578', 'OCD'],
    ['hive-167922', 'SteemLeo'],
    ['hive-136578', 'Steem Think Tank'],
    ['hive-177976', 'DCooperation'],
    ['hive-122359', 'Community Announce'],
    ['hive-185247', 'Open Source']
]
```
***

#### Creating and managing communities
All these transactions are actually Custom JSON transactions. [This](https://github.com/steemit/hivemind/blob/214-core/hive/indexer/community.py#L259) module will give an insight. Once things go out of the beta, I'll release a helper module in Lightsteem to make things easier.

#### Note
These API signatures may subject the change. GIT repository is a good place to track the changes if you're interested.

#### Vote for my witness
If you didn't vote already, consider casting a vote  for my witness on [ Steemconnect](https://steemconnect.com/sign/account-witness-vote?witness=emrebeyler&approve=1) or on [Steemit](https://steemit.com/~witnesses)

#### Python community

*This is originally posted on [Python community](https://beta.steemit.com/trending/hive-129924) in [Steemit Beta](https://beta.steemit.com/trending/hive-129924).* Check it out and subscribe if you're interested in Python related content.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 150 others
properties (23)
authoremrebeyler
permlinkexploring-new-hivemind-community-apis
categoryhive-129924
json_metadata{"tags":["python","hivemind","communities","lightsteem","development"],"image":["https://i.imgur.com/XcssYgI.png"],"links":["https://beta.steemit.com/","https://github.com/steemit/hivemind/blob/214-core/hive/server/serve.py#L115","https://lightsteem.readthedocs.io/en/latest/","https://github.com/steemit/hivemind/blob/214-core/hive/indexer/community.py#L259","https://steemconnect.com/sign/account-witness-vote?witness=emrebeyler&approve=1","https://steemit.com/~witnesses","https://beta.steemit.com/trending/hive-129924"],"app":"steemit/0.2","format":"markdown"}
created2020-01-14 21:21:45
last_update2020-01-14 21:21:45
depth0
children10
last_payout2020-01-21 21:21:45
cashout_time1969-12-31 23:59:59
total_payout_value7.373 HBD
curator_payout_value6.860 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,189
author_reputation448,535,049,068,622
root_title"Exploring new Hivemind Community APIs"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id94,402,992
net_rshares50,385,569,238,474
author_curate_reward""
vote details (214)
@imwatsi ·
Great stuff!
properties (22)
authorimwatsi
permlinkq4jw96
categoryhive-129924
json_metadata{"app":"steemit/0.2"}
created2020-01-23 08:15:09
last_update2020-01-23 08:15:09
depth1
children0
last_payout2020-01-30 08:15:09
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_length12
author_reputation131,386,362,730,495
root_title"Exploring new Hivemind Community APIs"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id94,675,966
net_rshares0
@mstafford · (edited)
Hoping to finally getting around to spinning up my own HiveMind node in the next week or two here.

I have a couple questions, in the meantime:

* Is there a public HiveMind node available for testing purposes? I remember seeing you post something about your hivemind.emrebeyler.me -- is that still up and public?

* Does @holger80's beempy library work with HiveMind nodes? Is that what the [```Discussions```](https://beem.readthedocs.io/en/latest/beem.discussions.html) module is all about?
👍  
properties (23)
authormstafford
permlinkre-emrebeyler-q45wqz
categoryhive-129924
json_metadata{"tags":["hive-129924"],"app":"steempeak/2.2.6"}
created2020-01-15 18:59:24
last_update2020-01-15 19:00:12
depth1
children8
last_payout2020-01-22 18:59:24
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_length493
author_reputation63,425,345,982,192
root_title"Exploring new Hivemind Community APIs"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id94,433,252
net_rshares0
author_curate_reward""
vote details (1)
@emrebeyler ·
`hivemind.emrebeyler.me`is up and running but it's running the stable version - communities feature is excluded.

No idea about beempy, I don't think it has a Hivemind module.
properties (22)
authoremrebeyler
permlinkq45x8t
categoryhive-129924
json_metadata{"app":"steemit/0.1"}
created2020-01-15 19:09:57
last_update2020-01-15 19:09:57
depth2
children7
last_payout2020-01-22 19:09:57
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_length175
author_reputation448,535,049,068,622
root_title"Exploring new Hivemind Community APIs"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id94,433,511
net_rshares0
@mstafford · (edited)
Ah okay. Thanks for the reply.

At the end of the day -- I'm developing a Steem project using Django. I'm not 100% certain, but I'm pretty sure that running an instance of my own Hivemind node would alleviate some of the issues I've been experiencing (generally related to issues with the "tags api" not being accessible, I think -- which was part of what was deprecated from original full nodes, yeah? Things like getting a list of replies to a post, and stuff like that, seems to throw errors for a while now) with just relying on the node-list incorporated into ```beempy```.

***

Does it sound like Hivemind would be a worthwhile step, or am I going down the wrong path here?
properties (22)
authormstafford
permlinkre-emrebeyler-q45xsd
categoryhive-129924
json_metadata{"tags":["hive-129924"],"app":"steempeak/2.2.6"}
created2020-01-15 19:21:51
last_update2020-01-15 19:22:18
depth3
children6
last_payout2020-01-22 19:21: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_length680
author_reputation63,425,345,982,192
root_title"Exploring new Hivemind Community APIs"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id94,433,773
net_rshares0